/* Local Fonts for Offline Support */
@font-face {
    font-family: 'Press Start 2P';
    font-style: normal;
    font-weight: 400;
    src: url('assets/fonts/PressStart2P.ttf') format('truetype');
}

@font-face {
    font-family: 'VT323';
    font-style: normal;
    font-weight: 400;
    src: url('assets/fonts/VT323.ttf') format('truetype');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 400;
    src: url('assets/fonts/Inter-Regular.ttf') format('truetype');
}

@font-face {
    font-family: 'Inter';
    font-style: normal;
    font-weight: 600;
    src: url('assets/fonts/Inter-SemiBold.ttf') format('truetype');
}

/* Variables */
:root {
    --main-bg: #1a1a1a;
    --chat-bg: #2d2d2d;
    --user-msg-bg: #404040;
    /* Subtle dark gray for user bubble */
    --loutre-msg-bg: #444444;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --loutre-accent: #00ff9d;
    /* Matrix/Cyber Green */
    --border-color: #333;
    --font-pixel: 'Press Start 2P', cursive;
    --font-mono: 'VT323', monospace;
    --font-family: 'Inter', sans-serif;
    /* Setup Inter as main font */
    --font-family: 'Inter', sans-serif;
    /* Setup Inter as main font */
    --input-bg: #2d2d2d;
    --hover-bg: #3d3d3d;
}

/* Surface Mode (Light Theme) */
body.surface-mode {
    --main-bg: #e0f7fa;
    /* Light Blue River */
    --chat-bg: #ffffff;
    --user-msg-bg: #f1f8e9;
    /* Light Greenish */
    --loutre-msg-bg: #e1f5fe;
    /* Light Blueish */
    --text-primary: #2c3e50;
    --text-secondary: #546e7a;
    --loutre-accent: #006064;
    /* Even Darker Teal for visibility */
    --border-color: #90a4ae;
    --input-bg: #e1f5fe;
    /* Slight blue tint, not pure white */
    --hover-bg: #b3e5fc;
}

/* Ambient Layer */
#ambient-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
    /* Behind everything */
    overflow: hidden;
}

.ambient-item {
    position: absolute;
    font-size: 2rem;
    opacity: 0.6;
    user-select: none;
    will-change: left, top, transform;
}

.ambient-item.small-bubble {
    font-size: 0.8rem;
    opacity: 0.4;
    filter: blur(1px);
}

/* --- Realistic Fish Animations --- */

/* Variation 1: Wave (Up and Down pitch) */
@keyframes swimRightWave {
    0% {
        left: -15vw;
        transform: translateY(0) scaleX(-1) rotate(0deg);
    }

    25% {
        transform: translateY(20px) scaleX(-1) rotate(5deg);
    }

    50% {
        transform: translateY(-10px) scaleX(-1) rotate(-5deg);
    }

    75% {
        transform: translateY(20px) scaleX(-1) rotate(5deg);
    }

    100% {
        left: 110vw;
        transform: translateY(0) scaleX(-1) rotate(0deg);
    }
}

@keyframes swimLeftWave {
    0% {
        left: 110vw;
        transform: translateY(0) scaleX(1) rotate(0deg);
    }

    25% {
        transform: translateY(20px) scaleX(1) rotate(-5deg);
    }

    50% {
        transform: translateY(-10px) scaleX(1) rotate(5deg);
    }

    75% {
        transform: translateY(20px) scaleX(1) rotate(-5deg);
    }

    100% {
        left: -15vw;
        transform: translateY(0) scaleX(1) rotate(0deg);
    }
}

/* Variation 2: Dash (Speed burst) */
@keyframes swimRightDash {
    0% {
        left: -15vw;
        animation-timing-function: ease-out;
    }

    40% {
        left: 40vw;
        animation-timing-function: linear;
    }

    /* Slow down */
    60% {
        left: 50vw;
        animation-timing-function: ease-in;
    }

    /* Speed up */
    100% {
        left: 110vw;
    }
}

@keyframes swimLeftDash {
    0% {
        left: 110vw;
        animation-timing-function: ease-out;
    }

    40% {
        left: 60vw;
        animation-timing-function: linear;
    }

    60% {
        left: 50vw;
        animation-timing-function: ease-in;
    }

    100% {
        left: -15vw;
    }
}

/* Inventory Delete Button */
.pebble-item {
    position: relative;
    /* ... existing styles ... */
}

.pebble-delete-btn {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4444;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    border: 1px solid white;
}

.pebble-item:hover .pebble-delete-btn {
    opacity: 1;
}

@media (hover: none) {

    /* Always show on touch devices */
    .pebble-delete-btn {
        opacity: 1;
    }
}

/* Variation 3: Steady (Linear Deep glide) */
@keyframes swimRightSteady {
    from {
        left: -15vw;
        transform: scaleX(-1);
    }

    to {
        left: 110vw;
        transform: scaleX(-1);
    }
}

@keyframes swimLeftSteady {
    from {
        left: 110vw;
        transform: scaleX(1);
    }

    to {
        left: -15vw;
        transform: scaleX(1);
    }
}

@keyframes bubbleRise {
    0% {
        bottom: -10vh;
        transform: translateX(0);
        opacity: 0;
    }

    10% {
        opacity: 0.6;
    }

    25% {
        transform: translateX(15px);
    }

    50% {
        transform: translateX(-10px);
    }

    75% {
        transform: translateX(10px);
    }

    100% {
        bottom: 120vh;
        transform: translateX(0);
        opacity: 0;
    }
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Layout */
body {
    background-color: var(--main-bg);
    color: var(--text-primary);
    font-family: var(--font-family);
    margin: 0;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    transition: background-color 0.3s ease;
}

.app-container {
    display: flex;
    width: 100vw;
    /* Full width */
    height: 100vh;
    /* Full height */
    max-width: none;
    /* No max width */
    background: transparent;
    /* No box effect */
    border: none;
    box-shadow: none;
    overflow: hidden;
    position: relative;
    z-index: 2;
    border-radius: 0;
}

/* Re-enable clicks for interface elements */
.sidebar,
.main-chat,
.modal {
    pointer-events: auto;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: rgba(30, 30, 30, 0.8);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 20px;
    z-index: 10;
    /* Above ambient layer */
}

.new-chat-btn {
    border: 1px solid #333;
    border-radius: 5px;
    padding: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
    color: var(--text-primary);
    background-color: #111;
}

.new-chat-btn:hover {
    background-color: var(--hover-bg);
}

.otter-sidebar-display {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-top: 1px solid #111;
    border-bottom: 1px solid #111;
}

#otter-sprite {
    width: 220px;
    /* Much bigger as requested */
    height: 220px;
    image-rendering: pixelated;
    object-fit: contain;
    /* Removed drop-shadow to avoid highlighting the box if any */
}

.history-list {
    flex: 1;
    margin-top: 20px;
    overflow-y: auto;
}

.history-item {
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-item:hover {
    background-color: var(--hover-bg);
    color: var(--text-primary);
}

.sidebar-footer {
    padding-top: 10px;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    padding: 10px;
    cursor: pointer;
    border-radius: 5px;
}

.user-profile:hover {
    background-color: var(--hover-bg);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--input-bg);
    padding: 30px;
    border-radius: 10px;
    max-width: 500px;
    text-align: center;
    border: 2px solid var(--loutre-accent);
    color: var(--text-primary);
    position: relative;
    /* For absolute positioning of close button */
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--loutre-accent);
}

/* Remove bullets and default padding from modal lists */
.modal-content ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.modal-content h2 {
    margin-bottom: 20px;
    color: var(--loutre-accent);
}

.modal-content p {
    margin-bottom: 15px;
    line-height: 1.5;
}

.modal-close-btn {
    margin-top: 20px;
    background: var(--loutre-accent);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
}

.modal-close-btn:hover {
    background: #008ba3;
}

/* Main Chat Area */
.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background-color: var(--main-bg);
}

/* Suggestions */
.suggestions-container {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    overflow-x: auto;
    padding-bottom: 5px;
    justify-content: center;
    flex-wrap: wrap;
}

.suggestion-chip {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 8px 16px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.suggestion-chip:hover {
    background: var(--hover-bg);
    color: var(--text-primary);
    border-color: var(--loutre-accent);
}

/* Chat Footer */
.chat-footer {
    padding: 20px;
    background-color: var(--main-bg);
    border-top: 1px solid #333;
    width: 100%;
    /* Ensure footer stays at bottom */
}

/* Model Selector (Header) */
.model-selector-container {
    position: relative;
    padding: 10px;
    text-align: center;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: center;
    z-index: 100;
}

.model-selector-btn {
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-weight: bold;
    font-size: 0.95rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 6px;
    font-family: var(--font-family);
    transition: background 0.2s, color 0.2s;
}

.model-selector-btn:hover {
    background: #333;
    color: var(--text-primary);
}

.model-selector-btn .arrow {
    font-size: 0.7rem;
    opacity: 0.7;
    transition: transform 0.2s;
}

.model-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(10px);
    background: #252525;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 6px;
    width: 250px;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
}

.model-menu.show {
    display: flex;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.model-option {
    padding: 12px;
    text-align: left;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.model-option:hover {
    background: #333;
}

.model-option.selected {
    background: #3a3a3a;
}

.model-option.selected .model-name {
    color: var(--loutre-accent);
}

.model-name {
    font-weight: bold;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.model-desc {
    font-size: 0.8rem;
    color: #888;
}

/* Sidebar Display */
.otter-sidebar-display {
    text-align: center;
    padding: 30px 10px;
    /* More breathing room */
    border-bottom: 1px solid #333;
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* The original #otter-sprite for the main chat area */
#otter-sprite {
    width: 200px;
    /* MUCH BIGGER (was 64/120?) */
    height: 200px;
    image-rendering: pixelated;
    /* Keep pixel art crisp */
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    /* Nice pop */
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    /* Bouncy transition */
}

/* Start clean status */
.status-text {
    font-size: 0.8rem;
    color: var(--loutre-accent);
    margin-top: 15px;
    text-align: center;
    font-family: 'Press Start 2P', monospace;
    line-height: 1.4;
    margin-top: 10px;
    min-height: 3em;
    /* Reserve space for 2 lines */
}

/* Tamagotchi Actions */
.tamagotchi-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    /* Slightly more gap */
    margin-top: 15px;
    width: 100%;
}

.action-btn {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn:hover {
    background: var(--hover-bg);
    transform: scale(1.1);
    border-color: var(--loutre-accent);
}

.action-btn:active {
    transform: scale(0.95);
}

/* Animations */
@keyframes float {
    0% {
        transform: translateY(0px);
    }

    50% {
        transform: translateY(-5px);
    }

    100% {
        transform: translateY(0px);
    }
}

@keyframes happy-bounce {

    0%,
    100% {
        transform: scale(1);
    }

    25% {
        transform: scale(1.1) rotate(-5deg);
    }

    75% {
        transform: scale(1.1) rotate(5deg);
    }
}

/* Living Otter Class */
#otter-sprite.living-breath {
    animation: float 3s ease-in-out infinite;
}

#otter-sprite.living-happy {
    animation: happy-bounce 0.8s ease-in-out infinite alternate;
    filter: brightness(1.1) saturate(1.2);
}

#otter-sprite.mood-sad {
    animation: float 6s ease-in-out infinite;
    /* Slower */
    filter: grayscale(0.6) brightness(0.9) sepia(0.2);
    transform: scale(0.95);
}

/* Chat Messages */
.chat-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 20px 20px 80px 20px;
    /* Add extra bottom padding for breathing room */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    scroll-behavior: smooth;
}

.message {
    width: 100%;
    max-width: 800px;
    padding: 0;
    /* Removing padding from container, handling in bubbles */
    display: flex;
    gap: 15px;
    line-height: 1.6;
}

.message.user-message {
    background-color: transparent;
    flex-direction: row-reverse;
    /* Avatar on right */
    justify-content: flex-start;
}

.message.user-message .message-content {
    background-color: var(--user-msg-bg);
    padding: 12px 18px;
    border-radius: 18px 4px 18px 18px;
    /* Bubble shape */
    max-width: 80%;
    /* Don't stretch full width */
}

/* Loutre message styling to match bubble aesthetic nicely or keep stripe?
   User only asked for user message change. But let's ensure alignment is good. */
.message.loutre-message {
    background-color: transparent;
    justify-content: flex-start;
}


.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 2px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.user-avatar {
    background-color: #5436DA;
}

.loutre-avatar {
    background: none;
}

.loutre-avatar img {
    width: 100%;
    height: 100%;
    image-rendering: pixelated;
}

.message-content {
    flex: 1;
    font-size: 1rem;
}

.message-name {
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.9rem;
}

/* Input Area */
.input-container {
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--main-bg);
    /* Opaque to hide scroll behind */
}

.input-box-wrapper {
    width: 100%;
    max-width: 800px;
    position: relative;
    background-color: var(--input-bg);
    border-radius: 12px;
    border: 1px solid #444;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    display: flex;
    display: flex;
    align-items: center;
    /* Center vertically for single line */
    padding: 5px 10px;
    background-color: var(--chat-bg);
    /* Use lighter bg for input area */
}

.input-box-wrapper:focus-within {
    border-color: #666;
}

#user-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1rem;
    padding: 10px;
    outline: none;
    font-family: var(--font-family);
    resize: none;
    /* No manual resize */
    min-height: 44px;
    /* Sufficient touch target */
    max-height: 200px;
    line-height: 1.5;
}

button#send-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 5px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, color 0.2s;
}

button#send-btn:hover:not(:disabled) {
    background-color: var(--loutre-accent);
    color: #fff;
}

button#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Input Actions (Plus Button) */
.input-actions {
    position: relative;
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.plus-btn {
    width: 32px;
    height: 32px;
    background: #404040;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    padding-bottom: 2px;
    /* Optical correction for + */
}

.plus-btn:hover {
    background: #505050;
    border-color: #777;
    transform: scale(1.05);
}

.plus-menu {
    position: absolute;
    bottom: 50px;
    left: 0;
    background: #252525;
    border: 1px solid #444;
    border-radius: 12px;
    padding: 8px;
    display: none;
    /* Hidden by default */
    flex-direction: column;
    min-width: 180px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.plus-menu.show {
    display: flex;
    animation: menuPopIn 0.2s ease-out;
}

@keyframes menuPopIn {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.menu-item {
    background: transparent;
    border: none;
    color: var(--text-primary);
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    font-family: var(--font-family);
}

.menu-item:hover {
    background: #3a3a3a;
}

.menu-item .icon {
    font-size: 1.1rem;
}

.loading-bar-container {
    width: 100%;
    max-width: 800px;
    height: 4px;
    background: #333;
    margin-top: 10px;
    border-radius: 2px;
    overflow: hidden;
    display: none;
}

.loading-bar {
    height: 100%;
    width: 0%;
    background-color: var(--loutre-accent);
    transition: width 0.3s;
}

.loading-text {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.disclaimer {
    font-size: 0.75rem;
    color: #666;
    margin-top: 10px;
    text-align: center;
    padding-bottom: 20px;
    /* Safe space from bottom edge */
}

/* Download Area */
.download-container {
    width: 100%;
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

.download-card {
    background: #1a1a1a;
    border: 1px solid var(--loutre-accent);
    padding: 30px;
    border-radius: 10px;
    text-align: center;
    max-width: 400px;
    box-shadow: 0 0 20px rgba(0, 188, 212, 0.1);
}

.download-card h3 {
    color: var(--loutre-accent);
    margin-bottom: 15px;
}

.download-card p {
    color: var(--text-secondary);
    margin-bottom: 25px;
    font-size: 0.9rem;
    line-height: 1.5;
}

.download-btn {
    background: var(--loutre-accent);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    transition: transform 0.2s, background 0.2s;
    width: 100%;
}

.download-btn:hover {
    background: #008ba3;
    transform: translateY(-2px);
}

.download-btn:disabled {
    background: #444;
    cursor: not-allowed;
    transform: none;
}

/* Custom Otter Loader */
.loutre-message-loader {
    width: 100%;
    max-width: 800px;
    padding: 0 20px;
    display: flex;
    justify-content: flex-start;
    /* Align left like loutre message */
    margin-bottom: 20px;
}

.loader-content {
    background: #252525;
    padding: 10px 20px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border: 1px solid #333;
}

.spinning-shell {
    font-size: 1.5rem;
    animation: spin 2s infinite linear;
    display: inline-block;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Animations */
@keyframes float {
    0% {
        transform: translateY(0px) rotate(0deg);
    }

    50% {
        transform: translateY(-3px);
    }

    100% {
        transform: translateY(0px) rotate(0deg);
    }
}

#otter-sprite {
    animation: float 4s ease-in-out infinite;
}

/* --- AMBIENT LAYER & CREATURES --- */
#ambient-layer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    /* Let clicks pass through empty space */
    z-index: 1;
    /* Above background, below UI */
    overflow: hidden;
}

/* Bubbles */
.bubble {
    position: absolute;
    bottom: -50px;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.1));
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    opacity: 0.6;
    animation: bubbleRise var(--rise-time) ease-in infinite;
}

@keyframes bubbleRise {
    0% {
        transform: translateY(110vh) scale(1);
        opacity: 0;
    }

    10% {
        opacity: 0.5;
    }

    50% {
        transform: translateY(50vh) scale(1.1);
    }

    100% {
        transform: translateY(-10vh) scale(1);
        opacity: 0;
    }
}

/* Inventory Styles */
.inventory-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 15px;
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
    padding-right: 15px;
    /* Adjust for scrollbar */
    padding-top: 10px;
    /* Space for delete buttons */
}

.pebble-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    font-size: 0.9em;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.pebble-item span {
    font-size: 0.8em;
    color: #ccc;
}

.empty-bag {
    color: #888;
    font-style: italic;
    text-align: center;
    margin-top: 20px;
}

/* Creatures (Shrimp, Fish) */
.creature {
    position: absolute;
    font-size: 2rem;
    opacity: 0.8;
    pointer-events: auto;
    /* Allow clicking on fish */
    cursor: crosshair;
    z-index: 10;
}

/* Swim Right */
/* Swim Right (Emoji faces Left, must flip to face Right) */
@keyframes swimRight {
    0% {
        transform: translateX(-10vw) scaleX(-1) rotate(5deg);
    }

    50% {
        transform: translateX(50vw) translateY(20px) scaleX(-1) rotate(-5deg);
    }

    100% {
        transform: translateX(110vw) scaleX(-1) rotate(5deg);
    }
}

/* Swim Left (Mirrored) */
@keyframes swimLeft {
    0% {
        transform: translateX(110vw) scaleX(1) rotate(5deg);
    }

    50% {
        transform: translateX(50vw) translateY(-20px) scaleX(1) rotate(-5deg);
    }

    100% {
        transform: translateX(-10vw) scaleX(1) rotate(5deg);
    }
}

/* --- TOASTS (Global) --- */
#toast-container {
    position: fixed;
    /* Fixed is better than absolute for overlaying EVERYTHING */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2147483647;
    /* Max integer value to be safe */
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    align-items: center;
    width: auto;
    height: auto;
}

.toast {
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 20px 30px;
    /* Bigger padding for center notif */
    border-radius: 12px;
    border: 2px solid var(--loutre-accent);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    font-family: var(--font-family);
    font-size: 1.1rem;
    /* Bigger text */
    display: flex;
    flex-direction: column;
    /* Stack content */
    align-items: center;
    gap: 10px;
    animation: toastPopIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    pointer-events: auto;
    min-width: 300px;
    justify-content: center;
    text-align: center;
}

.toast.fade-out {
    animation: toastFadeOut 0.5s ease-in forwards;
}

@keyframes toastPopIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes toastFadeOut {
    from {
        opacity: 1;
    }

    to {
        opacity: 0;
        transform: translateY(-20px);
    }
}


/* Message Images & Download Wrapper (Global) */
.chat-image-wrapper {
    position: relative;
    display: inline-block;
    margin-top: 10px;
}

.chat-image {
    max-width: 300px;
    max-height: 300px;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: block;
    object-fit: cover;
    transition: transform 0.2s;
}

.download-overlay-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    opacity: 0;
    transition: opacity 0.2s, background 0.2s, transform 0.2s;
    cursor: pointer;
    font-size: 1.5rem;
    z-index: 100;
}

.download-overlay-btn:hover {
    background: var(--loutre-accent);
    border-color: white;
    transform: scale(1.1);
}

.chat-image-wrapper:hover .download-overlay-btn {
    opacity: 1;
}

/* --- MOBILE RESPONSIVENESS --- */
@media (max-width: 768px) {

    /* Main Layout: Stack Vertical */
    .app-container {
        flex-direction: column;
        overflow: hidden;
        /* Prevent body scroll */
    }

    /* Sidebar becomes Top Header */
    .sidebar {
        width: 100%;
        height: auto;
        min-height: 140px;
        /* Space for Otter */
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 5px 10px;
        border-right: none;
        border-bottom: 1px solid #333;
        z-index: 50;
        background-color: var(--main-bg);
        flex-shrink: 0;
    }

    /* Compact Header Elements */
    .new-chat-btn span,
    .user-profile span {
        display: none;
        /* Hide text labels, keep icons if any (or just hide whole block) */
    }

    .new-chat-btn,
    .user-profile {
        width: 40px;
        padding: 5px;
        justify-content: center;
        background: transparent;
        border: none;
    }

    .sidebar-header,
    .sidebar-footer {
        flex: 0 0 auto;
        width: auto;
        padding: 0;
        margin: 0;
    }

    /* Otter Display: Optimize for Horizontal Top Bar */
    .otter-sidebar-display {
        flex-direction: row;
        border: none;
        padding: 2px;
        background: transparent;
        justify-content: center;
        align-items: center;
        gap: 15px;
        width: 100%;
    }

    #otter-sprite {
        width: 90px;
        height: 90px;
        transition: all 0.3s ease;
    }

    .status-text {
        font-size: 0.6rem;
        min-height: auto;
        max-width: 100px;
        text-align: left;
        margin: 0;
    }

    .tamagotchi-actions {
        flex-direction: column;
        gap: 5px;
        margin-top: 0;
    }

    .action-btn {
        width: 32px;
        height: 32px;
        font-size: 1rem;
    }

    /* Chat Area */
    .main-chat {
        height: calc(100% - 140px);
        /* Fill remaining space */
        width: 100%;
    }

    .model-selector {
        display: none;
        /* Save space */
    }

    .chat-scroll-area {
        padding: 10px 10px 80px 10px;
    }

    .message {
        max-width: 100%;
        gap: 10px;
    }

    .message.user-message .message-content,
    .message.loutre-message .message-content {
        max-width: 85%;
        font-size: 0.95rem;
    }



    .message-avatar {
        width: 28px;
        /* Slightly smaller avatars */
        height: 28px;
    }

    /* Input Area */
    .chat-footer {
        padding: 10px;
    }

    .input-container {
        padding: 0;
    }

    .disclaimer {
        font-size: 0.6rem;
    }

    /* Hide specific desktop-only visual flair if needed */
    /* Bubbles enabled on mobile too */
    .bubble {
        display: block;
        opacity: 0.3;
        /* Less intrusive on mobile */
    }

    /* Message Images */
    .chat-image-wrapper:hover .download-overlay-btn {
        opacity: 1;
    }
}