:root {
    --background-color: #0d1018;
    --line-color: rgba(230, 230, 230, 0.6);
    --accent-color: #EDFF00;
    --text-color: #ffffff;
    --selection-pink: #ff69b4;
    --feedback-font: 'Alex Brush', cursive;
}

body[data-theme='ocean'] {
    --background-color: #021024;
    --line-color: rgba(122, 196, 222, 0.6);
    --accent-color: #72cce3;
}

body[data-theme='fire'] {
    --background-color: #1a0000;
    --line-color: rgba(255, 170, 0, 0.6);
    --accent-color: #ff4500;
}

body[data-theme='space'] {
    --background-color: #000000;
    --line-color: rgba(200, 160, 220, 0.6);
    --accent-color: #dda0dd;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    overflow: hidden;
    transition: background-color 0.5s ease;
}

::selection {
    background-color: var(--selection-pink);
    color: var(--background-color);
}

#background-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.ui-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    padding: 20px;
    pointer-events: none;
    /* Prevent layout shift when mobile keyboard appears/disappears */
    transform: translateZ(0);
    will-change: transform;
}

.ui-container > * {
    pointer-events: auto;
}

@keyframes fade-in-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.input-wrapper {
    position: relative;
    width: 100%;
    max-width: 600px;
    animation: fade-in-up 0.8s ease-out 0.2s forwards;
    opacity: 0;
}

#chat-input {
    width: 100%;
    padding: 18px 25px;
    font-size: 1.2em;
    color: var(--text-color);
    background-color: rgba(10, 10, 10, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50px;
    outline: none;
    transition: all 0.3s ease;
    position: relative;
    z-index: 2;
}

#chat-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

#chat-input:focus {
    border-color: transparent;
    box-shadow: none;
}

.glow-border {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50px;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.input-wrapper.glowing .glow-border {
    opacity: 1;
    box-shadow: 0 0 20px #EDFF00, 0 0 40px #EDFF00, 0 0 60px #EDFF00;
}

#feedback-message {
    margin-bottom: 25px;
    font-family: var(--feedback-font);
    font-style: italic;
    font-size: 2.2em;
    color: var(--accent-color);
    min-height: 50px;
    width: 100%;
    max-width: 800px;
    transition: color 0.5s ease;
    text-align: center;
}

.carved-char {
    display: inline-block;
    opacity: 0;
    animation: carved-effect 0.5s forwards;
}

@keyframes carved-effect {
    from {
        opacity: 0;
        text-shadow: 0 0 10px #000;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        text-shadow: 0 0 8px var(--accent-color);
        transform: scale(1);
    }
}

.smoky-char {
    display: inline-block;
    opacity: 0;
    animation: smoky-appear 1s forwards;
}

@keyframes smoky-appear {
    0% {
        opacity: 0;
        filter: blur(8px);
        transform: translateY(20px) scale(0.8);
    }
    100% {
        opacity: 1;
        filter: blur(0px);
        transform: translateY(0px) scale(1);
    }
}

/* Optimize animations for better performance */
.smoky-char, .carved-char {
    will-change: opacity, transform;
    backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Mobile Optimization for 16:9 and 20:9 aspect ratios */
@media screen and (max-width: 768px) {
    .ui-container {
        padding: 15px;
        padding-bottom: max(15px, env(safe-area-inset-bottom));
    }

    .input-wrapper {
        max-width: 100%;
    }

    #chat-input {
        padding: 15px 20px;
        font-size: 1.1em;
    }

    #feedback-message {
        font-size: 1.8em;
        margin-bottom: 20px;
        max-width: 100%;
        padding: 0 10px;
    }
}

@media screen and (max-width: 480px) {
    .ui-container {
        padding: 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    #chat-input {
        padding: 12px 18px;
        font-size: 1em;
    }

    #feedback-message {
        font-size: 1.5em;
        margin-bottom: 15px;
    }
}

/* Specific optimization for tall mobile screens (20:9 aspect ratio) */
@media screen and (max-width: 480px) and (min-aspect-ratio: 18/9) {
    .ui-container {
        padding: 20px 12px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    #feedback-message {
        margin-bottom: 30px;
    }
}