@import url('https://fonts.googleapis.com/css2?family=Indie+Flower&display=swap');

*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    --header-height: 72px; /* 50px logo + 20px padding + 2px border */
    --logo-orange: #E4A044;
    --logo-blue: #59BFFF;
    --primary-color: var(--logo-blue);
    --background-color: #1c2833;
    --surface-color: #273746;
    --text-color: #efeff1;
    --text-color-secondary: #adadb8;
    --bottom-nav-height: 60px;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Indie Flower', cursive;
    background-color: var(--background-color);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='100' height='100' viewBox='0 0 100 100'%3E%3Cg fill='%23273746' fill-opacity='0.2'%3E%3Cpath d='M8 23c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM32 9c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM56 23c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM80 9c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM8 69c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM32 55c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM56 69c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM80 55c2-3 4-4 4-6 0-3-2-5-5-5s-5 2-5 5c0 2 2 3 4 6zM20 37c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7zM44 43c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7zM68 37c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7zM92 43c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7zM20 83c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7zM44 89c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7zM68 83c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7zM92 89c5 0 8-3 8-7s-3-7-8-7-8 3-8 7 3 7 8 7z'%3E%3C/path%3E%3C/g%3E%3C/svg%3E");
    color: var(--text-color);
    overscroll-behavior: none;
    height: 100dvh;
    padding-top: var(--header-height);
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
}

#welcome-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    z-index: 3000;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease-in-out;
}

#welcome-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#welcome-modal {
    background-color: var(--surface-color);
    padding: 2em;
    border-radius: 16px;
    border: 2px solid var(--logo-blue);
    text-align: center;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

.welcome-image {
    max-width: 150px;
    margin-bottom: 1em;
}

#close-welcome-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-color);
    cursor: pointer;
}

#welcome-modal a {
    color: var(--logo-orange);
    text-decoration: none;
    font-weight: bold;
}

#welcome-modal a:hover {
    text-decoration: underline;
}

#chat-issue-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.75);
    z-index: 3001;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.3s ease-in-out;
}

#chat-issue-modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

#chat-issue-modal {
    background-color: var(--surface-color);
    padding: 2em;
    border-radius: 16px;
    border: 2px solid var(--logo-orange);
    text-align: center;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
}

.chat-issue-logo {
    max-width: 120px;
    margin-bottom: 1em;
}

#close-chat-issue-modal {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-color);
    cursor: pointer;
}

#install-instructions-container {
    margin-top: 1em;
    padding: 1em;
    background-color: rgba(0,0,0,0.2);
    border-radius: 8px;
}

#install-instructions-container p {
    margin: 0;
    font-weight: bold;
    color: var(--logo-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
}

#install-instructions-container img, 
#install-instructions-container svg {
    height: 24px;
    width: 24px;
}

#install-popup {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 400px;
    background-color: var(--surface-color);
    border: 2px solid var(--logo-orange);
    border-radius: 16px;
    padding: 20px;
    z-index: 2000;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
    transition: opacity 0.3s, transform 0.3s;
    color: var(--logo-blue);
}

#install-popup.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(200%);
    pointer-events: none;
}

.popup-logo {
    width: 60px;
    height: 60px;
    margin-bottom: 10px;
}

#close-install-popup {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-color);
    cursor: pointer;
}

#install-instructions {
    font-weight: bold;
    color: var(--logo-blue);
}

.main-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    z-index: 1100;
    padding: 10px;
    text-align: center;
    background-color: var(--surface-color);
    border-bottom: 2px solid var(--logo-orange);
}

.main-header .logo {
    height: 50px;
    width: auto;
    max-height: 100%;
    object-fit: contain;
}

#main-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    /* overflow: hidden; */ /* This was preventing the keyboard from appearing on some mobile browsers */
}

#controller-container {
    padding: 1em;
    background-color: var(--background-color);
    overflow-y: auto;
}

.remote-control {
    background: #3c4a56;
    border-radius: 20px;
    padding: 1.5em;
    max-width: 600px;
    margin: 0 auto;
    box-shadow: 0px 10px 20px rgba(0,0,0,0.3), inset 0px 0px 15px rgba(0,0,0,0.2);
}

.remote-header {
    text-align: center;
    margin-bottom: 1.5em;
    border-bottom: 2px solid var(--logo-blue);
    padding-bottom: 1em;
}

.remote-header h2 {
    margin: 0;
    color: var(--text-color);
}

.remote-header span {
    color: var(--logo-orange);
    font-weight: bold;
    font-size: 1.2em;
}

.koin-balance {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0,0,0,0.2);
    padding: 1em;
    border-radius: 10px;
    margin-bottom: 1.5em;
}

.koin-button {
    background-color: var(--logo-blue);
    color: white;
    border: none;
    padding: 0.5em 1em;
    border-radius: 8px;
    font-family: 'Indie Flower', cursive;
    font-size: 1em;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1em;
}

.remote-button {
    background: #4a5a6a;
    border: 2px solid #5a6a7a;
    border-radius: 12px;
    padding: 1em;
    color: var(--text-color);
    font-family: 'Indie Flower', cursive;
    font-size: 1.1em;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0px 4px 8px rgba(0,0,0,0.3);
    cursor: not-allowed;
    opacity: 0.7;
}

.remote-button.wide {
    grid-column: 1 / -1;
}

.button-label {
    margin-bottom: 0.5em;
}

.button-cost {
    font-weight: bold;
    color: var(--logo-orange);
}

.view {
    width: 100%;
    /* height: 100%; */ /* This was causing the overflow */
    display: flex;
    flex-direction: column;
    z-index: 1000;
    flex-grow: 1;
    min-height: 0;
}

#video-container {
    display: flex;
}

#chat-container {
    display: none;
}

#twitch-player, #twitch-chat-embed {
    width: 100%;
    height: 100%;
    flex-grow: 1;
}

#twitch-chat-embed {
    border: 0;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background-color: var(--surface-color);
    border-top: 1px solid var(--logo-orange);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1100;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-color-secondary);
    font-size: 14px;
    flex: 1;
    height: 100%;
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-icon {
    width: 28px;
    height: 28px;
    margin-bottom: 4px;
}

.live-dot {
    width: 24px;
    height: 24px;
    background-color: var(--logo-orange);
    border-radius: 50%;
    box-shadow: 0 0 8px var(--logo-orange);
    animation: pulse 2s infinite;
    margin-bottom: 4px;
}

.nav-icon-placeholder {
    display: block;
    width: 28px;
    height: 28px;
    margin-bottom: 4px;
    background-color: #505054;
    border-radius: 4px;
}

@keyframes pulse {
    0% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(228, 160, 68, 0.7);
    }
    70% {
        transform: scale(1);
        box-shadow: 0 0 0 10px rgba(228, 160, 68, 0);
    }
    100% {
        transform: scale(0.95);
        box-shadow: 0 0 0 0 rgba(228, 160, 68, 0);
    }
}

@media (min-width: 768px) {
    body {
        overflow: hidden;
        padding-bottom: var(--bottom-nav-height); /* Keep padding for desktop nav */
    }

    #main-content {
        flex-direction: row;
    }

    .view {
        display: flex !important;
        height: 100%;
    }

    #video-container {
        flex: 3;
    }

    #chat-container {
        flex: 1;
        border-left: 1px solid #404044;
        display: flex;
    }

    body.chat-only #video-container {
        display: none;
    }

    body.chat-only #chat-container {
        flex: 1 1 100%;
        border-left: none;
    }

    .main-header {
        display: block;
    }
    
    .bottom-nav {
        position: fixed;
    }
} 