@font-face {
    font-family: 'Tanseek Sans Pro ExtraBold';
    src: url('fonts/tanseek-extra-bold.otf') format('opentype');
    font-weight: 800;
    font-style: normal;
}

@font-face {
    font-family: 'OutlastRegular';
    src: url('fonts/OutlastRegular.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

:root {
    --bg-dark: #1a1a2e;
    --bg-panel: #16213e;
    --text-primary: #ffffff;
    --text-secondary: #0f3460;
    --accent: #e94560;

    --card-bronze-start: #AE8C63;
    --card-bronze-end: #5D4037;

    --card-silver-start: #E0E0E0;
    --card-silver-end: #757575;

    --card-gold-start: #FFD700;
    --card-gold-end: #FF8F00;

    --font-heading: 'Tanseek Sans Pro ExtraBold', 'Oswald', sans-serif;
    --font-card: 'OutlastRegular', 'Oswald', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-primary);
    height: 100vh;
    overflow-x: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styling */
.controls-panel {
    width: 350px;
    background-color: var(--bg-panel);
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid #333;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
    flex-shrink: 0;
}

.app-header h1 {
    font-family: var(--font-heading);
    color: #ffffff;
    /* Color changed to white */
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 2.4em;
    /* Reduced by 20% from 3em */
}

.app-header p {
    font-size: 0.9em;
    color: #ccc;
    margin-bottom: 20px;
}

.form-section {
    margin-bottom: 25px;
    border-bottom: 1px solid #333;
    padding-bottom: 15px;
}

.form-section h2 {
    font-family: var(--font-heading);
    font-size: 1.65em;
    /* Increased by 50% from 1.1em */
    color: #ffd700;
    margin-bottom: 10px;
}

.input-group,
.range-group {
    margin-bottom: 15px;
}

label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    font-weight: 500;
}

input[type="text"],
input[type="url"],
select {
    width: 100%;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #444;
    background-color: #2a2a40;
    color: #fff;
    font-family: var(--font-body);
}

input[type="range"] {
    width: 100%;
    cursor: pointer;
}

/* Preview Area */
.preview-area {
    position: relative;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at center, #2e2e4e, #1a1a2e);
    /* Default */
    padding: 88px 40px;
    transition: background 0.5s ease;
    /* Removed overflow:hidden to allow card tips/shadows to be visible */
}

.preview-bg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: url('img/background/palacioPlanalto.jpg');
    background-size: cover;
    background-position: center;
    opacity: 0.3;
    /* 30% transparency */
    z-index: 1;
    pointer-events: none;
}

.preview-bronze {
    background: radial-gradient(circle at center, #5d4037, #1a1a1a);
}

.preview-silver {
    background: radial-gradient(circle at center, #455a64, #1a1a1a);
}

.preview-gold {
    background: radial-gradient(circle at center, #827717, #1a1a1a);
}

.card-container {
    position: relative;
    z-index: 2;
    margin-bottom: 20px;
    perspective: 1000px;
}

/* Card Design - FIFA Style */
.card {
    width: 320px;
    height: 495px;
    /* Increased height by ~3% to accommodate typical FIFA card ratios without cutting footer */
    position: relative;
    /* Removed border-radius and overflow:hidden to prevent clipping the background image */
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transition: transform 0.3s ease;
    background-size: contain;
    /* Changed to contain to ensure the full image is always visible */
    background-repeat: no-repeat;
    background-position: center;
    color: #333;
    /* Default text color for inside card */
    display: flex;
    flex-direction: column;
    font-family: var(--font-card);
}

.card:hover {
    transform: translateY(-5px) rotateY(2deg);
}

/* Dynamic Themes */
.card-bronze {
    background-image: url('img/PlanoFundoCartaBronze.PNG');
    border-color: #3e2723;
}

.card-silver {
    background-image: url('img/PlanoFundoCartaPrata.PNG');
    border-color: #424242;
}

.card-gold {
    background-image: url('img/PlanoFundoCartaOuro.PNG');
    border-color: #bfa505;
}

/* Inner Card Structure */
.card-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image: url('data:image/svg+xml;utf8,<svg width="100" height="100" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg"><g fill="%23FFFFFF" fill-opacity="0.1"><path d="M50 0 L100 50 L50 100 L0 50 Z" /></g></svg>');
    opacity: 0.3;
    z-index: 1;
}

.card-top {
    position: relative;
    z-index: 5;
    display: flex;
    justify-content: space-between;
    padding: 25px 25px 0 25px;
    height: 120px;
}

.card-score-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    margin-top: 34px;
    /* Down 30px */
    margin-left: -5px;
    /* Left 5px */
    transform: translateX(-5px);
}

.overall-score {
    font-size: 3.5rem;
    font-weight: 700;
    line-height: 1;
}

.position-label {
    font-size: 1rem;
    text-transform: uppercase;
}

.position-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Center align since it's now under the score */
    margin-top: 5px;
}

.mandate-label {
    font-size: 0.8rem;
    opacity: 0.9;
    margin-top: -2px;
}

.municipality-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    line-height: 1.1;
    margin-top: 2px;
    max-width: 80px;
    text-align: center;
}

.card-flag-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    margin-top: 34px;
}

.state-flag {
    width: 43px;
    height: auto;
    border: 1px solid rgba(0, 0, 0, 0.2);
}

.party-logo {
    width: 43px;
    height: 43px;
    object-fit: contain;
}

.card-photo-container {
    position: relative;
    z-index: 4;
    height: 240px;
    width: 180px;
    margin: -70px auto 0;
    /* Overlap top area */
}

.card-photo-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    -webkit-mask-image: linear-gradient(to bottom, black 80%, transparent 100%);
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.3));
}

.card-name {
    position: relative;
    z-index: 5;
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    text-transform: none;
    margin-top: -35px;
    margin-bottom: 6px;
    letter-spacing: 0.5px;
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff;
}

.card-stats {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px 6px;
    /* Vertical gap 2px, Horizontal gap increased to 6px */
    padding: 0 20px 0 35px;
    margin-top: 16px;
    /* Moved down by 10px + 6px */
    /* Move down by 16px */
}

.stat-item {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    font-size: 1.1rem;
}

.stat-value {
    font-weight: 700;
    font-size: 1.3rem;
    margin-right: 5px;
    width: 30px;
    text-align: right;
    transition: text-shadow 0.3s ease;
}

.high-score {
    text-shadow:
        -1px -1px 0 #fff,
        1px -1px 0 #fff,
        -1px 1px 0 #fff,
        1px 1px 0 #fff,
        0px 0px 4px rgba(255, 255, 255, 0.8);
}

.stat-label {
    font-weight: 400;
    font-size: 0.9rem;
    opacity: 1;
    text-transform: uppercase;
    white-space: nowrap;
}

.card-bottom-bar {
    margin-top: auto;
    height: 15px;
    background: transparent;
    /* Changed to transparent to not cover the background image footer */
}

/* Help Trigger Styling */
.label-with-help {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 5px;
}

.label-with-help label {
    margin-bottom: 0;
    flex-grow: 1;
}

.help-trigger {
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
    border: 1px solid var(--accent);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    margin-left: 10px;
    font-weight: bold;
}

.help-trigger:hover {
    background: var(--accent);
    color: white;
    transform: scale(1.1);
}

.faq-info h3 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    color: #ffd700;
    margin-bottom: 10px;
}

.faq-info p {
    margin-bottom: 10px;
    line-height: 1.5;
}

/* FAQ Button & Modal Styling */
.header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.faq-toggle {
    background: var(--accent);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s ease;
    box-shadow: 0 4px 10px rgba(233, 69, 96, 0.3);
}

.faq-toggle:hover {
    transform: scale(1.1);
    background: #ff4d6d;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    opacity: 1;
}

.modal-card {
    background: #16213e;
    border: 1px solid #e9456044;
    width: 90%;
    max-width: 600px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card {
    transform: translateY(0);
}

.modal-header {
    background: #1a1a2e;
    padding: 20px 25px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #333;
}

.modal-header h2 {
    font-family: var(--font-heading);
    color: #ffd700;
    font-size: 1.8rem;
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.close-modal:hover {
    opacity: 1;
}

.modal-body {
    padding: 25px;
    max-height: 70vh;
    overflow-y: auto;
}

.faq-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

.faq-item {
    display: flex;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.faq-icon {
    font-size: 1.5rem;
    background: rgba(233, 69, 96, 0.1);
    min-width: 45px;
    height: 45px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 10px;
}

.faq-info h3 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    color: #fff;
    margin-bottom: 5px;
}

.faq-info p {
    font-size: 0.9rem;
    color: #ccc;
    line-height: 1.4;
}

.faq-info strong {
    color: #e94560;
}

/* Responsive */
@media (max-width: 800px) {
    .app-container {
        flex-direction: column;
        height: auto;
    }

    .controls-panel {
        width: 100%;
        max-height: 50vh;
        border-right: none;
        border-bottom: 1px solid #333;
    }

    .card-container {
        transform: scale(0.8);
        margin: -40px 0;
    }
}

/* Music Controls */
.music-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 100;
    display: flex;
    gap: 10px;
}

.music-btn {
    background: rgba(233, 69, 96, 0.2);
    color: #fff;
    border: 1px solid var(--accent);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    backdrop-filter: blur(5px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.music-btn:hover {
    background: var(--accent);
    transform: scale(1.1);
}

@media (max-width: 800px) {
    .music-controls {
        top: 10px;
        right: 10px;
    }
}