:root {
    --primary-gradient: linear-gradient(135deg, #6e8efb, #a777e3);
    --accent-color: #00d2ff;
    --success-color: #00e676;
    --danger-color: #ff5252;
    --dark-bg: #0f0c29;
    --card-bg: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --text-main: #ffffff;
    --text-muted: #e0e0e0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Montserrat', sans-serif;
}

input, button, select, textarea {
    font-family: 'Montserrat', sans-serif;
}

/* Scroll Indicator */
.scroll-indicator::after {
    content: '\f107';
    /* FontAwesome Down Arrow */
    font-family: 'Font Awesome 5 Free';
    font-weight: 900;
    font-size: 1.5rem;
    color: var(--text-muted);
    display: block;
    margin-top: 1rem;
    animation: bounce 2s infinite;
}

body {
    background: #000;
    background: linear-gradient(to bottom, #0f0c29, #302b63, #24243e);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

#app-header {
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

#author-note {
    font-size: 0.7rem;
    color: var(--text-muted);
}

#author-note a {
    color: var(--text-muted);
    text-decoration: underline;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    padding-bottom: 2rem;
    /* Espaço extra na parte inferior */
}

.screen {
    width: 100%;
    max-width: 500px;
    display: none;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Landing Page */
#landing-screen h1 {
    font-size: 2.5rem;
    margin-bottom: 2rem;
    text-shadow: 0 0 20px rgba(110, 142, 251, 0.5);
}

.btn-primary {
    background: var(--primary-gradient);
    border: none;
    padding: 1.2rem 3rem;
    border-radius: 50px;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(110, 142, 251, 0.3);
    transition: transform 0.2s;
}

.btn-primary:active {
    transform: scale(0.95);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* UF Screen */
/* Inputs & Selects Standard */
.styled-input,
#uf-select,
#partido-select,
.survey-input {
    width: 100%;
    padding: 1rem;
    border-radius: 10px;
    background: #1a1a2e;
    color: white;
    border: 1px solid var(--glass-border);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s;
}

.styled-input:focus,
#uf-select:focus,
#partido-select:focus,
.survey-input:focus {
    border-color: var(--accent-color);
}

option {
    background: #1a1a2e;
    color: white;
}

/* Escalas de Bolinhas (Radio Buttons customizados) */
.scale-group {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 5px;
    margin: 1rem 0;
    width: 100%;
}

.scale-item {
    position: relative;
    flex: 1;
    text-align: center;
}

.scale-item input[type="radio"] {
    display: none;
    /* Esconde o radio nativo */
}

.scale-item label {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 35px;
    height: 35px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid var(--glass-border);
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--text-muted);
    transition: all 0.2s;
    margin: 0 auto;
}

/* Hover */
.scale-item label:hover {
    border-color: var(--accent-color);
    background: rgba(0, 210, 255, 0.1);
}

/* Checado / Ativo */
.scale-item input[type="radio"]:checked+label {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-color);
    transform: scale(1.1);
}

/* Mobile adjustments for 11 items (0-10) */
@media (max-width: 480px) {
    .scale-item label {
        width: 25px;
        height: 25px;
        font-size: 0.7rem;
    }
}

/* Voting Stack */
#vote-stack {
    position: relative;
    width: 320px;
    height: 450px;
}


.vote-card {
    position: absolute;
    width: 100%;
    height: 100%;
    background: var(--card-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.5);
    user-select: none;
    touch-action: none;
    overflow: hidden;
}

.vote-card h2 {
    font-size: 1.4rem;
    margin-bottom: 0.8rem;
}

.vote-card p {
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 1rem;
}

.saiba-mais {
    color: #4fc3f7;
    /* High contrast blue */
    text-decoration: underline;
    font-weight: 700;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    display: inline-block;
}

/* Rankings */
.ranking-list {
    width: 100%;
    max-width: 600px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 20px;
    padding: 1rem;

    /* Scroll fix */
    max-height: 400px;
    /* Exibe uns 5 ou 6 deputados */
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color) rgba(0, 0, 0, 0.3);
}

.ranking-list::-webkit-scrollbar {
    width: 8px;
}

.ranking-list::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.ranking-list::-webkit-scrollbar-thumb {
    background-color: var(--accent-color);
    border-radius: 4px;
}

.ranking-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    border-bottom: 1px solid var(--glass-border);
    transition: background 0.2s;
}

.ranking-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.deputy-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    margin-right: 1rem;
    border: 2px solid var(--accent-color);
    background: #eee;
    overflow: hidden;
    flex-shrink: 0;
    position: relative;
    /* Container relativo para filhos absolutos */
}

.deputy-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
    /* Centraliza horizontalmente e foca no topo verticalmente */
    border: none;
    margin: 0;
    position: absolute;
    /* Cobre o ícone */
    top: 0;
    left: 0;
    z-index: 2;
    /* Fica acima do ícone */
    display: block;
    background: transparent;
    /* Garante transparência se opacity=0 */
    transition: opacity 0.2s;
}

.fallback-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #302b63;
    /* Tom roxo escuro solicitado */
    opacity: 0.8;
    /* Aumentada opacidade para melhor visibilidade */
    font-size: 1.8rem;
    z-index: 1;
    /* Fica atrás da imagem */
    width: auto !important;
    height: auto !important;
    display: block !important;
    /* Sempre visível atrás da foto */
}

.dep-info {
    flex: 1;
    text-align: left;
}

.match-pct {
    font-weight: bold;
    font-size: 1.2rem;
    color: var(--success-color);
}

/* Stamps */
.stamp {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-10deg);
    font-size: 5rem;
    font-weight: 900;
    padding: 1rem 2rem;
    border: 10px solid;
    border-radius: 20px;
    opacity: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.1s;
}

.stamp.sim {
    color: var(--success-color);
    border-color: var(--success-color);
}

.stamp.nao {
    color: var(--danger-color);
    border-color: var(--danger-color);
}

/* Social Icons */
.social-footer {
    padding: 2rem;
    display: flex;
    gap: 1.5rem;
}

.social-footer i {
    font-size: 1.5rem;
    color: var(--text-muted);
    transition: color 0.3s;
}

.social-footer i:hover {
    color: var(--accent-color);
}

/* Visibility Utilities */
.desktop-only {
    display: none;
}

@media (min-width: 768px) {
    .desktop-only {
        display: inline;
    }

    .mobile-only {
        display: none;
    }

    #vote-stack {
        width: 400px;
        height: 550px;
    }
}

/* Mobile Optimizations */
@media (max-width: 480px) {
    #app-header {
        padding: 0.5rem 1rem;
    }

    #brand-name {
        font-size: 1rem;
    }

    #landing-screen h1 {
        font-size: 1.8rem;
    }

    /* Ajuste crítico para evitar cortes vertical */
    #vote-stack {
        width: 85vw;
        height: 55vh;
        /* Reduzido para sobrar espaço para os botões */
        margin-top: 0.5rem;
        margin-bottom: 1rem;
    }

    .vote-card {
        padding: 1rem;
    }

    .vote-card h2 {
        font-size: 1.1rem;
        margin-bottom: 0.5rem;
    }

    .vote-card p {
        font-size: 0.85rem;
        line-height: 1.35;
        margin-bottom: 0.8rem;
    }

    .saiba-mais {
        font-size: 0.75rem;
        margin-bottom: 0.5rem;
    }

    /* Botões de controle (Sim/Não) */
    .controls {
        transform: scale(0.85);
        /* Reduz botões */
        margin-bottom: 1rem;
    }

    /* Ranking maior para aproveitar melhor a tela */
    .ranking-list {
        max-height: 50vh;
    }

    .btn-primary {
        padding: 0.8rem 1.5rem;
        font-size: 0.9rem;
        width: 100%;
    }

    /* Ajuste de margens gerais */
    main {
        padding: 0.5rem;
        padding-bottom: 1rem;
        justify-content: flex-start;
    }

    /* Otimiza telas UF e Demographic para aproveitar melhor o espaço */
    #uf-screen.active,
    #demographic-screen.active {
        min-height: auto;
        padding-top: 1rem;
        padding-bottom: 1rem;
    }

    /* Reduz espaçamento entre elementos nas telas de formulário */
    #uf-screen h2,
    #demographic-screen h2 {
        margin-bottom: 0.5rem;
        font-size: 1.3rem;
    }

    #uf-screen p,
    #demographic-screen p {
        margin-bottom: 0.5rem;
        font-size: 0.85rem;
    }

    /* Otimização específica para tela demográfica mobile */
    #demographic-screen .form-group {
        margin-bottom: 0.8rem;
    }

    #demographic-screen label {
        font-size: 0.85rem !important;
        margin-bottom: 0.3rem !important;
    }

    #demographic-screen select {
        padding: 0.6rem;
        font-size: 0.9rem;
    }

    #demographic-screen .scale-group {
        padding-bottom: 0.3rem !important;
    }

    #demographic-screen #view-match-btn {
        margin-top: 0.8rem !important;
        padding: 0.9rem 1rem;
        font-size: 0.85rem;
    }

    /* Tela de resultados otimizada */
    #results-screen.active {
        padding-top: 0.5rem;
        padding-bottom: 1.5rem;
        min-height: auto;
    }

    #results-screen h2 {
        margin-bottom: 0.3rem !important;
        font-size: 1.4rem;
    }

    #results-screen p {
        margin-bottom: 0.5rem !important;
        font-size: 0.8rem;
    }

    /* Metodologia com fonte menor */
    #results-screen p[style*="font-size:0.75rem"] {
        font-size: 0.7rem !important;
        margin-bottom: 0.8rem !important;
        line-height: 1.3;
    }

    /* Botão de compartilhar otimizado */
    #results-screen #share-results-btn {
        margin-top: 0.8rem !important;
        margin-bottom: 0.8rem !important;
        padding: 0.9rem 1rem;
        font-size: 0.9rem;
    }

    /* Link "Refazer Votação" */
    #results-screen p[onclick] {
        font-size: 0.8rem !important;
        margin-top: 0.5rem !important;
        margin-bottom: 0.8rem !important;
    }

    /* Centraliza apenas a tela inicial para ficar bonito */
    #landing-screen.active {
        min-height: 85vh;
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
}

/* Fix for modern mobile browsers (address bar) */
body {
    min-height: 100vh;
    min-height: 100dvh;
    /* Dynamic Viewport Height */
    overflow-y: auto;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-10px);
    }

    60% {
        transform: translateY(-5px);
    }
}