body {
    background: linear-gradient(45deg, rgba(26, 15, 46, 0.8), rgba(44, 24, 84, 0.8)), 
                url('https://omniakashica.com/wp-content/uploads/2024/11/Designer-40.jpeg');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    font-family: 'Arial', sans-serif;
    overflow-x: hidden;
}

.container {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding: 5px;
    perspective: 1000px;
    width: 100%;
    overflow-x: auto;
    position: relative;
    height: 590px;
    transform: rotateX(180deg); /* put scrollbar at top */
}

/* Wrapper that restores card visuals after container rotation */
.cards-wrapper {
    display: flex;
    flex-wrap: nowrap;
    transform: rotateX(180deg); /* flip back the content so cards appear normal */
    align-items: flex-start;
    gap: 0;
}

.card {
    width: 100px;
    height: 180px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
    cursor: pointer;
    margin-left: -90px;
    flex-shrink: 0;
}

.card:first-child {
    margin-left: 0;
}

.card:hover {
    z-index: 10;
}

.card.flipped {
    transform: rotateY(180deg) translateY(130px);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 10px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
}

.card-back {
    background: linear-gradient(135deg, #6b0f1a, #1a0f2e);
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.card-back img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.card-front {
    background: #000; /* changed from white to black */
    color: white;     /* ensure text is white */
    transform: rotateY(180deg);
    padding: 3px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    text-align: center;
    font-size: 11px;
}

.card-front img {
    width: 100%;
    height: 100%;
    margin: 0px 0;
    object-fit: contain;
}

.draggable {
    cursor: move;
    user-select: none;
}

#shuffle-btn, #reset-btn, #email-btn, #profissionais-btn, #home-btn, #jogo-btn, #help-btn, #api-btn, #pwa-btn {
    margin: 0;
    width: 100%; 
    padding: 4px 0; 
    font-size: 18px;
    background: linear-gradient(45deg, #6b0f1a, #1a0f2e);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s;
    text-align: center; 
    display: flex;
    align-items: center;
    justify-content: center;
}

#shuffle-btn:hover, #reset-btn:hover, #email-btn:hover, #profissionais-btn:hover, #home-btn:hover, #jogo-btn:hover, #help-btn:hover, #api-btn:hover, #pwa-btn:hover {
    transform: scale(1.1);
}

.button-container {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    align-items: stretch;
    width: 42px; /* reduced from 50px */
}

.button-container button {
    position: relative;
}

.tooltip {
    visibility: hidden;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(26, 15, 46, 0.9);
    color: white;
    text-align: center;
    border-radius: 6px;
    padding: 5px 10px;
    opacity: 0;
    transition: opacity 0.3s;
    white-space: nowrap;
    font-size: 12px;
    pointer-events: none;
}

.button-container button:hover .tooltip {
    visibility: visible;
    opacity: 1;
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: rgba(26, 15, 46, 0.9) transparent transparent transparent;
}

.floating-menu {
    position: fixed;
    top: 2px;
    right: 2px;
    background: rgba(26, 15, 46, 0.9);
    padding: 1px;
    border-radius: 5px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    cursor: move;
    z-index: 1000;
    user-select: none;
    backdrop-filter: blur(5px);
    border: 0px solid rgba(255,255,255,0.1);
    width: 42px; /* reduced from 44px */
}

/* Slightly smaller button container to match reduced menu */
.button-container {
    display: flex;
    flex-direction: column;
    gap: 0px;
    margin: 0;
    align-items: stretch;
    width: 42px; /* reduced from 50px */
}

/* Reduce button padding and font-size inside the floating menu for a more compact look */
.floating-menu .button-container button,
.floating-menu .button-container button span.tooltip {
    font-size: 15px; /* slightly smaller icons/text */
}

.floating-menu .button-container button {
    padding: 3px 0; /* slightly reduced padding */
    height: 36px; /* ensure touch-friendly but slightly smaller */
}

.floating-menu::before {
    content: '⋮⋮';
    display: block;
    text-align: center;
    color: white;
    margin-bottom: 10px;
    font-size: 20px;
}

.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px;
    background: rgba(26, 15, 46, 0.9);
    color: white;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: transform 0.3s ease-in-out;
}

.footer.minimized {
    transform: translateY(calc(100% - 80px));
}

.footer-toggle {
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
}

/* When footer is minimized, center the toggle horizontally */
.footer.minimized .footer-toggle {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

.footer-toggle:hover {
    opacity: 0.8;
}

.input-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

/* Ensure the input container can shrink on small screens so the input width adapts */
.input-row > div {
    flex: 1;
    min-width: 0; /* allow children to shrink properly on small viewports */
}

#pergunta {
    width: 100%;
    padding: 10px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 5px;
    color: white;
    font-family: 'Arial', sans-serif;
    box-sizing: border-box; /* make padding included in width calculations */
    max-width: 100%;
}

.resultadoCartas-btn {
    padding: 10px;
    background: linear-gradient(45deg, #6b0f1a, #1a0f2e);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    height: 40px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.resultadoCartas-btn:hover {
    transform: scale(1.05);
}

/* Microphone button in footer */
.mic-btn {
    margin-left: 8px;
    background: linear-gradient(45deg, #1a0f2e, #6b0f1a);
    color: white;
    border: none;
    border-radius: 8px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.3);
    transition: transform 0.12s, background 0.12s;
}

/* Visual state while listening */
.mic-btn.listening {
    background: linear-gradient(45deg, #ff4d4d, #6b0f1a);
    transform: scale(1.05);
    box-shadow: 0 6px 18px rgba(107,15,26,0.4);
}

.mic-btn:hover {
    transform: scale(1.03);
}

#flipped-cards {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-height: 60px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 5px;
    color: white;
    font-family: 'Arial', sans-serif;
    resize: vertical;
    margin-top: 10px;
}

.popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(26, 15, 46, 0.95);
    /* equal horizontal padding for consistent left/right spacing */
    padding: 24px;
    padding-top: 40px; /* keep a bit more top padding to match original visual */
    border-radius: 10px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    z-index: 2000;
    color: white;
    text-align: center; /* center text */
    max-width: 80%;
    width: calc(100% - 48px); /* ensure consistent side spacing on small viewports */
    box-sizing: border-box; /* include padding in width calculations */
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.1);
    white-space: pre-line;
    max-height: 80vh;
    overflow-y: auto;
    display: flex; /* Make it a flex container */
    flex-direction: column; /* Stack children vertically */
    align-items: center; /* Center children horizontally */
}

/* Specific styling for the tutorial/help popup: center text and equal horizontal spacing */
.popup.help-popup {
    padding: 20px;          /* equal padding on all sides */
    text-align: center;     /* center-align text */
    box-sizing: border-box; /* ensure padding doesn't overflow */
}

/* Ensure alert modal centers inside the overlay (override .popup fixed positioning) */
.popup.alert-modal {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    transform: none !important;
    margin: auto;
    max-width: 90%;
    width: calc(100% - 48px);
    box-sizing: border-box;
}

.popup.show {
    display: flex;
    animation: fadeIn 0.3s;
}

.close-popup {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

.close-popup:hover {
    transform: scale(1.1);
}

.popup .use-ai-btn {
    margin-top: 10px;
    padding: 10px 20px;
    background: linear-gradient(45deg, #6b0f1a, #1a0f2e);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s;
    display: inline-block;
}

.popup .use-ai-btn:hover {
    transform: scale(1.05);
}

.popup .copy-text-btn,
.popup .export-text-btn,
.popup .speak-btn {
    margin: 10px auto 0; /* Apply consistent centering margin */
    background: linear-gradient(45deg, #6b0f1a, #1a0f2e);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.3s;
    display: block; /* Ensure they are block elements to stack */
    padding: 10px 20px;
}

/* Speaking state visual for speak button */
.popup .speak-btn.speaking {
    background: linear-gradient(45deg, #ffb84d, #ff704d);
    transform: scale(1.03);
}

.popup .copy-text-btn:hover,
.popup .export-text-btn:hover {
    transform: scale(1.05);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.video-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.video-popup.show {
    display: flex;
}

.video-container {
    position: relative;
    width: 80%;
    max-width: 800px;
    padding: 20px;
    background: #1a0f2e;
    border-radius: 10px;
}

.close-video {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 30px;
    height: 30px;
    background: #6b0f1a;
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 20px;
    line-height: 30px;
    text-align: center;
}

.video-wrapper {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
}

.video-wrapper iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

.popup-link {
    display: block; /* Change to block to stack buttons */
    margin: 10px auto 0; /* Center and add top margin */
    padding: 10px 20px;
    background: linear-gradient(45deg, #6b0f1a, #1a0f2e);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: transform 0.2s;
    width: fit-content; /* Adjust width to content */
    border: none; /* Ensure no default button border */
    font-size: 16px; /* Adjust font size for consistency */
    cursor: pointer; /* Indicate clickable */
}

.popup-link:hover {
    transform: scale(1.05);
}

/* Mobile-specific styles for the popup */
@media (max-width: 600px) {
    .popup {
        width: 100%;
        max-width: none; /* Override max-width to allow full width */
        height: 100%; /* Occupy full height */
        top: 0;
        left: 0;
        transform: none; /* Remove centering transform */
        border-radius: 0; /* Remove border-radius for full-screen feel */
        padding: 20px 10px; /* Adjust padding for mobile screens */
        justify-content: flex-start; /* Align content to the top */
    }
    .popup .close-popup {
        top: 10px;
        right: 10px;
    }
    .popup h2 {
        margin-top: 0;
    }
}

/* Custom Scrollbar Styles (Webkit) to match site theme */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #1A0F2E; /* Dark background matching the theme */
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    /* Using the gradient from buttons/theme colors: #6b0f1a to #1a0f2e */
    background: linear-gradient(45deg, #6b0f1a, #1a0f2e); 
    border-radius: 10px;
    border: 1px solid rgba(107,15,26,0.6);
}

::-webkit-scrollbar-thumb:hover {
    background: #6b0f1a;
}