:root {
    --duo-principal: #35c2c4;
    --duo-principal-border: #0b8587;
    --duo-blue: #35c2c4;
    --duo-blue-border: #0b8587;
    --duo-gray: #e5e5e5;
    --duo-text: #4b4b4b;
    --duo-dark-code: #23272e;
    --duo-green-soft: #d7ffb8;
    --duo-green-text: #58a700;
    --duo-red-soft: #ffdfe0;
    --duo-red-text: #ea2b2b;
    --duo-red: #ff4b4b;
    --duo-red-border: #bb3939;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    color: var(--duo-text);
    background-color: white;
}
/* --- ANIMACIÓN --- */
.app-container {
    opacity: 0;
    transition: opacity 0.4s ease-in-out;
}

.app-container.loaded {
    opacity: 1;
}

/* PANTALLA DE CARGA */
#loader-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999; 
    transition: opacity 0.4s ease, visibility 0.4s;
}

.loader-circle {
    width: 60px;
    height: 60px;
    border: 6px solid var(--duo-gray);
    border-top: 6px solid var(--duo-principal); 
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

#loader-wrapper.hide {
    opacity: 0;
    visibility: hidden;
}

/* HEADER & NAVEGACIÓN */
.lesson-header {
    height: 70px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 2px solid var(--duo-gray);
    position: sticky;
    top: 0;
    background: white;
    z-index: 10;
}

.header-content {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 20px;
}

.progress-container {
    flex-grow: 1;
    background-color: var(--duo-gray);
    height: 16px;
    border-radius: 20px;
}

.progress-bar {
    background-color: var(--duo-principal);
    height: 100%;
    border-radius: 20px;
    transition: width 0.3s ease;
}

/* CONTENEDORES PRINCIPALES */
.exercise-container, .home-main {
    max-width: 600px;
    margin: 40px auto;
    padding: 0 20px;
}

.home-main {
    max-width: 800px;
    padding-bottom: 140px;
}

.instruction {
    font-size: 28px;
    margin-bottom: 20px;
    text-align: left;
}

.code-card {
    background: var(--duo-dark-code);
    color: #abb2bf;
    padding: 30px;
    border-radius: 15px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 22px;
    margin-bottom: 40px;
    box-shadow: 0 4px 0px #1a1d23;
}

.code-card-info {
    background-color: #ffffff; 
    color: #4b4b4b;
    border-radius: 15px;
    padding: 25px;
    border: 2px solid #e5e5e5;
    border-left: 8px solid var(--duo-blue); 
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    margin-bottom: 20px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.code-card-info h3 {
    color: var(--duo-blue);
    margin-top: 0;
    font-size: 1.4rem;
}

.drop-zone {
    border-bottom: 2px solid var(--duo-principal);
    color: var(--duo-principal);
    min-width: 60px;
    display: inline-block;
}

.unit-card {
    background-color: var(--duo-principal);
    color: white;
    border-radius: 15px;
    padding: 24px;
    margin: 40px 0px;
    box-shadow: 0 4px 0px var(--duo-principal-border);
}

.levels-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.level-node {
    width: 90px;
    height: 85px;
    background: var(--duo-gray);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    text-decoration: none;
    border-bottom: 6px solid #ccc;
    transition: all 0.1s;
    cursor: pointer;
    color: var(--duo-text);
}

.level-node.active {
    background: var(--duo-principal);
    border-color: var(--duo-principal-border);
    color: white;
}

.level-node:active {
    transform: translateY(4px);
    border-bottom-width: 2px;
}

.level-node.locked {
    background-color: #e5e5e5 !important;
    color: #afafaf !important;
    cursor: not-allowed;
    border: 2px solid #ccc !important;
    box-shadow: none !important;
    filter: grayscale(1);
}

.level-node.completed {
    background-color: #35c2c4 !important; 
    color: white !important;
    border-color: #0b8587 !important;
}

/* --- BOTONES Y OPCIONES --- */
.options-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.option-card {
    background: white;
    border: 2px solid var(--duo-gray);
    border-bottom: 4px solid var(--duo-gray);
    border-radius: 12px;
    padding: 15px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.1s;
    text-align: center;
}

.option-card:hover {
    background-color: #f7f7f7;
}

.option-card.selected {
    background-color: #ddf4ff;
    border-color: var(--duo-blue);
    color: var(--duo-blue);
    border-bottom-color: var(--duo-blue-border);
}

#container-btn-exit {
    display: flex;
    justify-content: center;
    margin-top: 30px; 
    width: 100%;
}

#container-btn-exit .btn-check {
    background-color: var(--duo-red);
    border-bottom: 4px solid var(--duo-red-border);
    width: auto; 
    min-width: 200px; 
}

#container-btn-exit .btn-check:active {
    border-bottom-width: 0;
    transform: translateY(4px);
}

.options-container {
    margin-bottom: 20px;
}

.btn-check {
    background-color: var(--duo-blue);
    border: none;
    border-bottom: 4px solid var(--duo-blue-border);
    border-radius: 12px;
    padding: 12px 40px;
    color: white;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    transition: filter 0.2s;
}

.btn-check:active {
    border-bottom-width: 0;
    transform: translateY(4px);
}

.btn-skip {
    background: none;
    border: none;
    color: #9b9b9b;
    font-weight: bold;
    font-size: 16px;
    cursor: pointer;
    text-decoration: none;
    padding: 12px 20px;
    border-radius: 12px;
}

.btn-skip:hover {
    background-color: var(--duo-gray);
    color: var(--duo-text);
}

.exit-btn {
    background: none;
    border: none;
    color: #9b9b9b;
    font-weight: bold;
    font-size: 18px;
    cursor: pointer;
}

/* LOGIN/REGISTER */
.auth-main {
    max-width: 400px;
    margin: 60px auto;
    padding: 0 20px;
    text-align: center;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.input-field {
    width: 100%;
    padding: 15px;
    border: 2px solid var(--duo-gray);
    border-radius: 12px;
    background-color: #f7f7f7;
    font-size: 16px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.2s;
}

.input-field:focus {
    border-color: var(--duo-blue);
    background-color: white;
}

.btn-full {
    width: 100%;
    margin-top: 10px;
}

.auth-divider {
    margin: 20px 0;
    color: #afafaf;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.auth-divider::before, .auth-divider::after {
    content: "";
    flex: 1;
    height: 2px;
    background: var(--duo-gray);
}

.auth-footer-text {
    margin-top: 25px;
    color: var(--duo-text);
}

.link-blue {
    color: var(--duo-blue);
    text-decoration: none;
    font-weight: bold;
}

/* LOGOUT */
#logout-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: white;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.6s ease-in-out;
}

#logout-overlay.show {
    opacity: 1;
}

.logout-content {
    text-align: center;
}

.logout-logo {
    width: 180px;
    height: auto;
    display: block;
    margin-bottom: 20px;
    transform: translateY(20px);
    opacity: 0;
    transition: all 0.8s ease-out 0.4s; 
}

.show .logout-logo {
    transform: translateY(0);
    opacity: 1;
}

.logout-text {
    font-family: Arial, sans-serif;
    color: #afafaf;
    font-weight: bold;
    font-size: 1.2rem;
    opacity: 0;
    transition: opacity 0.8s ease-out 0.8s;
}

.show .logout-text {
    opacity: 1;
}

/* MODAL ALERT */
.modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10001;
    visibility: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    visibility: visible;
    opacity: 1;
}

.modal-box {
    background: white;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    transform: scale(0.8);
    transition: all 0.3s ease;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

.modal-overlay.active .modal-box {
    transform: scale(1);
}

.modal-icon {
    font-size: 50px;
    color: var(--duo-principal);
    margin-bottom: 15px;
}

.modal-box h3 {
    margin: 0 0 10px;
    color: var(--duo-text);
}

.modal-box p {
    color: #777;
    margin-bottom: 25px;
}

/* --- MEJORAS MODAL LIGA --- */
.modal-rules-list {
    text-align: left;
    background: #f7f7f7;
    padding: 15px;
    border-radius: 12px;
    margin: 15px 0;
    list-style: none;
}

.modal-rules-list li {
    margin-bottom: 10px;
    display: flex;
    gap: 10px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--duo-text);
}

.modal-rules-list li i {
    color: var(--duo-principal);
    margin-top: 3px;
}

/* FOTO */
#imagen-a-recortar {
    display: block;
    max-width: 100%;
}

/* RACHA Y GEMAS */
.stats {
    display: flex;
    align-items: center;
    font-weight: bold;
    font-size: 16px;
}

.lives {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 10px;
    transition: background 0.2s;
}

.lives:hover {
    background: var(--duo-gray);
}

/* --- SECCIÓN DE LIGA (ESTILO DUOLINGO) --- */
.league-container {
    background: white;
    border: 2px solid var(--duo-gray);
    border-radius: 15px;
    margin-top: 20px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.league-container:active {
    transform: scale(0.98);
}

.league-header {
    padding: 15px;
    background: #f7f7f7;
    border-bottom: 2px solid var(--duo-gray);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.league-header span {
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    font-size: 14px;
}

.timer-badge {
    font-size: 12px;
    color: var(--duo-red);
    font-weight: bold;
    background: var(--duo-red-soft);
    padding: 4px 8px;
    border-radius: 8px;
}

.user-row {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--duo-gray);
    transition: background 0.2s;
}

.user-row:last-child {
    border-bottom: none;
}

.user-row.highlight {
    background-color: #ddf4ff;
    font-weight: bold;
}

.user-row.promotion {
    border-left: 4px solid #4cc9f0; 
    background: rgba(76, 201, 240, 0.05);
}

.rank {
    width: 35px;
    color: #afafaf;
    font-weight: 800;
    font-size: 14px;
}

.user-avatar-mini {
    width: 32px;
    height: 32px;
    background: var(--duo-gray);
    border-radius: 50%;
    margin: 0 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
}

.user-info {
    flex-grow: 1;
    font-size: 16px;
    color: var(--duo-text);
}

.exp {
    font-weight: 800;
    color: #afafaf;
    font-size: 14px;
}

.user-row.highlight .exp {
    color: var(--duo-blue);
}

#user-racha { color: #ff9600; } 
#user-gemas { color: #1cb0f6; } 

/* SETTINGS */
.input-codex-disabled {
    width: 100%;
    padding: 12px 40px 12px 12px; 
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    background-color: #f7f7f7;
    color: #777;
    font-size: 16px;
    font-weight: bold;
    outline: none;
    transition: all 0.3s ease;
}

.input-codex-disabled.editing {
    background-color: white;
    border-color: var(--duo-blue);
    color: var(--duo-text);
}

.input-container-relative {
    position: relative;
    display: flex;
    align-items: center;
}

.edit-icon {
    position: absolute;
    right: 15px;
    color: #afafaf;
    cursor: pointer;
    transition: color 0.2s;
}

.edit-icon:hover {
    color: var(--duo-blue);
}

.config-label {
    display:block; 
    font-weight:bold; 
    color:#afafaf; 
    font-size:12px; 
    margin-bottom:5px;
}

/* FEEDBACK */
.feedback-modal {
    position: fixed;
    bottom: -300px; 
    left: 0;
    width: 100%;
    min-height: 180px; 
    display: flex;
    align-items: center;
    transition: bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 200;
    padding: 20px 0; 
}

.feedback-modal.active {
    bottom: 0;
}

.feedback-modal.active.correct {
    background: var(--duo-green-soft);
    bottom: 0;
}

.feedback-modal.active.incorrect {
        background: var(--duo-red-soft);
    bottom: 0;
}

.feedback-modal.correct #btn-next-step {
    background-color: #58cc02; 
    border-bottom: 4px solid #46a302;
}

.feedback-modal.incorrect #btn-next-step {
    background-color: #ff4b4b; 
    border-bottom: 4px solid #d33131;
    color: white;
}

.feedback-content {
    max-width: 1000px;
    margin: 0 auto;
    width: 100%;
    padding: 0 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 30px;
}

.feedback-text {
    display: flex;
    flex-direction: column; 
    align-items: flex-start;
    gap: 8px; 
    flex: 1; 
}

.feedback-extra {
    font-size: 15px;
    opacity: 0.9;
    line-height: 1.4;
    margin-top: 5px;
    font-weight: 400;
}

.feedback-text h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
}

.feedback-text p {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.feedback-modal .btn-check {
    padding: 15px 30px;
    min-width: 180px;
    cursor: pointer;
}

.info-slide {
    text-align: left;
    font-size: 1.1rem;
    line-height: 1.6;
    padding: 10px;
}

.info-img {
    display: block;
    max-width: 100%;
    margin: 20px auto;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}

.feedback-modal.correct .btn-check { background-color: var(--duo-green-text); border-color: #468400; }
.feedback-modal.incorrect .btn-check { background-color: var(--duo-red-text); border-color: #c42424; }