:root {
    --primary: #84cc16; /* Lime/Green Bio-based */
    --primary-hover: #65a30d;
    --accent: #fbbf24; /* Gold */
    --bg-dark: #0f172a; 
    --bg-card: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --glass: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --shadow-premium: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --font-main: 'Outfit', sans-serif;
    --safe-area: 20px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    letter-spacing: normal;
    word-spacing: normal;
}

body {
    font-family: var(--font-main);
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-viewport {
    width: 100%;
    max-width: 450px; /* Mobile focused */
    height: 100%;
    max-height: 900px;
    background: var(--bg-dark);
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-premium);
}

@media (min-width: 768px) {
    #game-viewport {
        border-radius: 40px;
        height: 90vh;
        border: 8px solid #1e293b;
        margin: auto;
    }
}

/* Screen Management */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: var(--safe-area);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s;
    z-index: 1;
}

.screen.active {
    opacity: 1;
    visibility: visible;
    z-index: 10;
}

/* Typography & Headers */
.screen-header {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 20px;
}

.logo-placeholder {
    font-weight: 800;
    font-size: 1.2rem;
    margin-bottom: 16px;
    color: var(--text-main);
}

.logo-placeholder .accent {
    color: var(--primary);
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(to bottom, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p {
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1.5;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border: none;
    padding: 16px 32px;
    border-radius: 16px;
    color: #000;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    width: 100%;
    box-shadow: 0 10px 15px -3px rgba(251, 191, 36, 0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 20px 25px -5px rgba(251, 191, 36, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(1);
}

/* Avatar Selection Reverted */
.selection-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 100%;
    flex-grow: 1;
    padding: 10px;
    overflow-y: auto;
}

.avatar-details {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 20px;
    text-align: center;
    margin-bottom: 10px;
}

.details-image-wrapper {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary);
    margin: 0 auto 15px;
}

.details-image-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.details-text h2 {
    font-size: 1.5rem;
    margin-bottom: 4px;
}

.details-text h4 {
    color: var(--primary);
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.details-text p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 20px;
    line-height: 1.4;
}

.avatar-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    width: 100%;
    padding-bottom: 20px;
}

.avatar-item {
    background: var(--glass);
    border: 2px solid var(--glass-border);
    border-radius: 20px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
}

.avatar-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
}

.avatar-item.selected {
    border-color: var(--primary);
    background: rgba(251, 191, 36, 0.1);
    transform: scale(1.05);
}

.avatar-image {
    width: 100%;
    aspect-ratio: 1;
    background: #1e293b;
    border-radius: 50%;
    margin-bottom: 12px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: breath 3s ease-in-out infinite;
    border: 2px solid var(--glass-border);
}

@keyframes breath {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.avatar-name {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Map Screen */
#screen-map {
    padding: 0;
}

.map-container {
    flex-grow: 1;
    position: relative;
    background: #0a0f1d;
    overflow: hidden;
}

#map-svg-wrapper {
    width: 100%;
    height: 100%;
    position: relative;
    background-image: url('assets/Fondo_quizz-01.jpg');
    background-size: cover;
    background-position: center;
    opacity: 1; /* Full visibility */
}

.map-avatar {
    width: 60px;
    height: 60px;
    background: transparent;
    position: absolute;
    z-index: 100;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.5));
    display: flex;
    justify-content: center;
    align-items: center;
    transform: translate(-50%, -100%); /* Bottom centered on point */
    border: none;
    pointer-events: none;
}

.map-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Show full image */
    border-radius: 0;
}

.map-point {
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    position: absolute;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
    transition: transform 0.3s;
    transform: translate(-50%, -50%); /* Center on coordinate */
}

.map-point.mission {
    width: 20px;
    height: 20px;
    background: var(--accent);
    border: 2px solid white;
}

.map-point.path {
    width: 10px;
    height: 10px;
    background: rgba(255, 255, 255, 0.4);
}

.map-point.active {
    background: var(--primary);
    transform: translate(-50%, -50%) scale(1.5);
    box-shadow: 0 0 20px var(--primary);
    animation: pulse-point 1.5s infinite;
}

.path-dot {
    width: 6px;
    height: 6px;
    background: white; /* More opaque */
    border-radius: 50%;
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 50;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
}

@keyframes pulse-point {
    0% { box-shadow: 0 0 0 0 rgba(132, 204, 22, 0.7); }
    70% { box-shadow: 0 0 0 15px rgba(132, 204, 22, 0); }
    100% { box-shadow: 0 0 0 0 rgba(132, 204, 22, 0); }
}

.map-ui-overlay {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    padding: 16px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.progress-bar-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    margin-bottom: 12px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.5s ease;
}

/* Quiz Card */
.quiz-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
}

.quiz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.timer {
    width: 50px;
    height: 50px;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

.circular-chart {
    position: absolute;
    width: 100%;
    height: 100%;
}

.circle {
    stroke: var(--primary);
    fill: none;
    stroke-width: 2.8;
    stroke-linecap: round;
    transition: stroke-dasharray 0.3s linear;
}

#timer-text {
    font-weight: 800;
    font-size: 1.2rem;
}

h2 {
    font-size: 1.4rem;
    line-height: 1.4;
    margin-bottom: 32px;
    font-weight: 700;
}

.options-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 18px;
    border-radius: 16px;
    color: white;
    text-align: left;
    font-family: inherit;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.option-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.option-btn.correct {
    background: #10b981; /* Green */
    border-color: #059669;
}

.option-btn.wrong {
    background: #ef4444; /* Red */
    border-color: #dc2626;
}

/* Results Screen */
.results-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border-radius: 32px;
    padding: 40px;
    text-align: center;
    border: 1px solid var(--glass-border);
    margin: auto;
    width: 100%;
    max-width: 600px;
}

.score-circle {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto 24px;
    color: #000;
    box-shadow: 0 20px 40px rgba(251, 191, 36, 0.3);
}

#final-score {
    font-size: 2.5rem;
    font-weight: 800;
}

.premium-form {
    margin-top: 32px;
    text-align: left;
}

.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

input[type="text"],
input[type="email"] {
    width: 100%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    padding: 14px 16px;
    border-radius: 12px;
    color: white;
    font-family: inherit;
    transition: border-color 0.3s;
}

input:focus {
    outline: none;
    border-color: var(--primary);
}

/* Overlay Panels */
.overlay-panel {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    transform: translateY(20px);
}

.overlay-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.overlay-panel.full {
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-dark);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.dialogue-content {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    border: 1px solid var(--primary);
    border-radius: 24px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
}

.dialogue-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    border: 2px solid white;
    overflow: hidden;
}

.dialogue-text-wrapper h4 {
    color: var(--primary);
    font-size: 0.8rem;
    text-transform: uppercase;
    margin-bottom: 4px;
}

.dialogue-text-wrapper p {
    color: white;
    font-size: 0.95rem;
    line-height: 1.4;
}

.btn-small {
    background: var(--primary);
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    color: black;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: auto;
}

/* Spinner & Loader */
.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--glass);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loader-content h3 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}
