/* VARIABLES INSTITUCIONALES Y GAMIFICADAS */
:root {
    --tahiti-gold: #D8820A;
    --fuel-yellow: #EBA71F;
    --redwood: #69200D;
    --white: #FFFFFF;
    --cream: #FFF8ED;
    --dark-grey: #2B2B2B;
    --dark-brown: #351006;
    --warm-black: #1A1110;
    
    --success-green: #2ecc71;
    --error-red: #e74c3c;
    --suspect-orange: #f39c12;
    
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Inter', sans-serif;
}

/* RESET BASICO */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--warm-black);
    color: var(--dark-grey);
    line-height: 1.6;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    background-color: var(--cream);
    position: relative;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
}

/* UTILIDADES Y TEXTO */
h1, h2, h3, h4 {
    font-family: var(--font-heading);
    color: var(--dark-brown);
    margin-bottom: 15px;
    text-transform: uppercase;
    text-align: center;
}

h4 { font-size: 1rem; margin-bottom: 5px; }
.text-green { color: var(--success-green); }
.text-red { color: var(--error-red); }
.mt-2 { margin-top: 1rem; }
.mt-4 { margin-top: 2rem; }
.mb-2 { margin-bottom: 1rem; }
.text-small { font-size: 0.9rem; line-height: 1.4; color: #555; }
.text-center { text-align: center; }
.text-left { text-align: left; }
.title-huge { font-size: 2.5rem; }

.flex-center {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

/* HEADER Y NAVEGACION */
header {
    background: linear-gradient(to right, var(--dark-brown), var(--redwood));
    padding: 10px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--white);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    z-index: 10;
    position: sticky;
    top: 0;
}
.logo {
    height: 35px;
    object-fit: contain;
}
.score-display {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 800;
    background: var(--fuel-yellow);
    color: var(--dark-brown);
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 0 var(--tahiti-gold);
}

/* PANTALLAS */
.screen {
    padding: 20px;
    flex: 1;
    display: none;
    animation: fadeIn 0.4s ease-in-out;
}
.screen.active {
    display: block;
}
.screen.flex-center.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ESTILOS INICIO */
.home-container {
    text-align: center;
    padding-top: 20px;
}
.main-logo {
    max-width: 220px;
    margin-bottom: 10px;
}
.game-title {
    color: var(--redwood);
    font-size: 2.2rem;
    line-height: 1.1;
    margin-bottom: 5px;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}
.game-subtitle {
    color: var(--tahiti-gold);
    font-size: 1.3rem;
    margin-bottom: 15px;
}
.home-avatar-container {
    margin: 10px auto;
}
.personaje-inicio {
    width: min(280px, 70vw);
    height: auto;
    display: block;
    margin: 24px auto;
    object-fit: contain;
    filter: drop-shadow(0 18px 28px rgba(53, 16, 6, 0.25));
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
    100% { transform: translateY(0px); }
}

.home-intro {
    font-size: 1.05rem;
    margin-bottom: 20px;
    padding: 0 10px;
    font-weight: 600;
}

/* BOTONES ESTILO FORTNITE / GAMIFICADO */
.btn {
    font-family: var(--font-heading);
    font-weight: 800;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.1s;
    text-align: center;
    display: inline-block;
}
.btn-primary {
    background-color: var(--fuel-yellow);
    color: var(--dark-brown);
    box-shadow: 0 6px 0 var(--tahiti-gold);
    padding: 15px 25px;
    font-size: 1.1rem;
}
.btn-secondary {
    background-color: var(--redwood);
    color: var(--white);
    box-shadow: 0 6px 0 var(--dark-brown);
    padding: 12px 20px;
    font-size: 1rem;
}
.btn-large {
    font-size: 1.3rem;
    padding: 20px;
}
.btn-small {
    padding: 5px 15px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: bold;
    background: var(--fuel-yellow);
    color: var(--dark-brown);
    border: none;
    box-shadow: 0 4px 0 var(--tahiti-gold);
    cursor: pointer;
}
.btn-full { width: 100%; display: block; }
.btn-push:active {
    transform: translateY(6px);
    box-shadow: 0 0px 0 transparent;
}
.btn:disabled {
    background-color: #ccc !important;
    box-shadow: 0 6px 0 #999 !important;
    color: #666 !important;
    cursor: not-allowed;
    transform: translateY(0);
}
.animate-pulse {
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 6px 0 var(--tahiti-gold); }
    50% { transform: scale(1.05); box-shadow: 0 6px 15px var(--tahiti-gold); }
    100% { transform: scale(1); box-shadow: 0 6px 0 var(--tahiti-gold); }
}

/* TARJETAS Y PANELES */
.card, .panel {
    background: var(--white);
    border-radius: 16px;
    padding: 20px;
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    border: 2px solid rgba(0,0,0,0.05);
}
.panel-light {
    background: var(--cream);
    border: 2px dashed var(--tahiti-gold);
}

/* LISTA DE INSTRUCCIONES */
.instructions-list {
    list-style: none;
    text-align: left;
    margin: 20px 0;
}
.instructions-list li {
    margin-bottom: 15px;
    font-size: 1.05rem;
    display: flex;
    align-items: center;
}
.instructions-list .icon {
    font-size: 1.5rem;
    margin-right: 15px;
}

/* MAPA DE RUTA */
.map-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.btn-zone {
    display: flex;
    align-items: center;
    background: var(--white);
    border: 3px solid var(--tahiti-gold);
    border-radius: 16px;
    padding: 12px;
    cursor: pointer;
    box-shadow: 0 6px 0 var(--tahiti-gold);
    transition: all 0.2s;
    text-align: left;
}
.btn-zone:active { transform: translateY(6px); box-shadow: 0 0 0 var(--tahiti-gold); }
.btn-zone .zone-number {
    background: var(--fuel-yellow);
    color: var(--dark-brown);
    font-family: var(--font-heading);
    font-weight: 900;
    width: 35px;
    height: 35px;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 50%;
    font-size: 1.1rem;
    margin-right: 15px;
    flex-shrink: 0;
}
.btn-zone .zone-name {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    color: var(--dark-brown);
}
.btn-zone.locked {
    background: #e0e0e0; border-color: #b0b0b0; box-shadow: 0 6px 0 #b0b0b0; cursor: not-allowed; opacity: 0.8;
}
.btn-zone.locked .zone-number { background: #b0b0b0; color: #fff; }
.btn-zone.locked .zone-name { color: #666; }

/* ZONAS Y RETOS */
.zone-header {
    background: var(--redwood);
    color: var(--white);
    padding: 12px;
    text-align: center;
    font-family: var(--font-heading);
    font-size: 1.1rem;
    border-radius: 12px;
    margin-bottom: 15px;
    box-shadow: 0 4px 0 var(--dark-brown);
}
.reto-container {
    display: none;
    animation: fadeIn 0.3s;
}
.reto-container.active { display: block; }

/* RETO 1: MONEDAS */
.coin-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--white);
    padding: 12px;
    border-radius: 12px;
    margin-bottom: 10px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.1);
    font-weight: 600;
    font-size: 0.95rem;
}
.coin-item .controls {
    display: flex;
    align-items: center;
    gap: 10px;
}
.coin-val {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

/* OPCIONES / BOTONES MULTIPLE CHOICE */
.options-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
}
.btn-option {
    background: var(--white);
    border: 2px solid var(--tahiti-gold);
    color: var(--dark-grey);
    padding: 12px;
    border-radius: 12px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}
.btn-option:hover { background: var(--cream); }
.btn-option.selected {
    background: var(--fuel-yellow);
    border-color: var(--tahiti-gold);
    color: var(--dark-brown);
    font-weight: 700;
}

/* DRAG AND DROP */
.draggables-pool {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 15px 0;
    padding: 15px;
    background: rgba(0,0,0,0.05);
    border-radius: 12px;
    min-height: 80px;
}
.draggable-card {
    background: var(--fuel-yellow);
    color: var(--dark-brown);
    padding: 8px 12px;
    border-radius: 8px;
    font-weight: bold;
    font-size: 0.9rem;
    cursor: grab;
    box-shadow: 0 3px 0 var(--tahiti-gold);
    user-select: none;
    touch-action: none; /* Previene scroll en móvil mientras se arrastra */
    transition: all 0.2s;
    display: inline-block;
}
.draggable-card:active { cursor: grabbing; box-shadow: none; transform: translateY(3px); }
.card-dragging { opacity: 0.5; }
.card-selected {
    box-shadow: 0 0 10px var(--redwood), 0 3px 0 var(--tahiti-gold) !important;
    transform: scale(1.05) !important;
    border: 2px solid var(--redwood);
}
.drop-zones-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 15px;
}
.drop-zone-container h4 {
    font-size: 0.95rem;
    background: var(--redwood);
    color: white;
    padding: 5px;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
}
.drop-zone {
    background: var(--white);
    border: 2px dashed #ccc;
    border-radius: 0 0 8px 8px;
    min-height: 80px;
    padding: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    transition: background 0.2s, border-color 0.2s;
    cursor: pointer;
}
.drop-zone.drag-over, .drop-zone-hover, .drop-zone-active {
    background: #e8f8f5;
    border-color: var(--success-green);
    border-style: solid;
}
.drop-zone.green-border { border-color: #27ae60; }
.drop-zone.red-border { border-color: #c0392b; }
.drop-zone-filled { background: #fdfdfd; }

/* RETO 10 SEGMENTOS */
.segments-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 15px;
}
.segment-box {
    display: flex;
    align-items: center;
    background: white;
    border: 2px solid var(--tahiti-gold);
    border-radius: 8px;
    padding: 5px;
}
.segment-label {
    flex: 1;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 5px;
}
.segment-drop {
    width: 120px;
    min-height: 40px;
    border: 2px dashed #ccc;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fafafa;
}

/* CAZA DE ESTAFAS (RETO 8) */
.notifications-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-top: 15px;
}
.notification-card {
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    border-left: 5px solid var(--tahiti-gold);
}
.notification-text {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 10px;
}
.notification-actions {
    display: flex;
    gap: 10px;
}
.btn-safe, .btn-suspect {
    flex: 1;
    padding: 8px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: #f9f9f9;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-safe.selected { background: var(--success-green); border-color: #27ae60; color: white; }
.btn-suspect.selected { background: var(--error-red); border-color: #c0392b; color: white; }

/* RETO 7: CLAVE */
.form-input {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 2px solid #ddd;
    border-radius: 12px;
    font-family: var(--font-body);
    margin-bottom: 10px;
    outline: none;
}
.form-input:focus { border-color: var(--tahiti-gold); }
.password-strength-container { margin: 15px 0; }
.strength-bar-bg { height: 10px; background: #ddd; border-radius: 5px; overflow: hidden; }
.strength-bar { height: 100%; width: 0%; transition: all 0.3s ease; }
.pwd-criteria { list-style: none; font-size: 0.85rem; text-align: left; }

/* RETO 12: ORDENAR RUTA */
.order-container { display: flex; flex-direction: column; gap: 8px; margin-bottom: 15px; }
.btn-order {
    background: var(--white);
    border: 2px solid var(--tahiti-gold);
    padding: 10px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
}
.selected-order {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-height: 120px;
    background: #f9f9f9;
    padding: 10px;
    border-radius: 8px;
    border: 2px dashed #ccc;
}
.order-item-list {
    background: var(--fuel-yellow);
    padding: 6px 10px;
    border-radius: 6px;
    font-weight: bold;
    color: var(--dark-brown);
    font-size: 0.9rem;
}

/* INSIGNIAS Y TROFEO */
.insignia-card {
    background: linear-gradient(135deg, var(--fuel-yellow), var(--tahiti-gold));
    padding: 30px 20px;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(216, 130, 10, 0.4);
    text-align: center;
    color: var(--dark-brown);
    border: 4px solid var(--white);
    width: 90%;
    max-width: 350px;
}
.insignia-icon { font-size: 4rem; margin: 15px 0; text-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.insignia-name { font-size: 1.3rem; font-weight: 900; }

/* RESULTADO */
.trophy-img { max-width: 180px; margin: 0 auto 15px auto; display: block; }
.moodle-box { border: 3px solid var(--tahiti-gold); padding: 15px; }
.code-display {
    font-family: monospace;
    font-size: 1.3rem;
    background: #eee;
    padding: 10px;
    border-radius: 8px;
    margin: 10px 0;
    font-weight: bold;
    color: var(--redwood);
    letter-spacing: 2px;
}

/* MODALES */
.modal {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--white);
    padding: 25px;
    border-radius: 16px;
    text-align: center;
    max-width: 90%;
    width: 320px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    animation: bounceIn 0.4s;
}
@keyframes bounceIn {
    0% { transform: scale(0.8); opacity: 0; }
    60% { transform: scale(1.05); opacity: 1; }
    100% { transform: scale(1); }
}

/* CANVAS CERTIFICADO */
.canvas-wrapper {
    width: 100%;
    overflow-x: auto; /* Para móvil permite scroll si no cabe */
    border: none;
    border-radius: 8px;
    background: transparent;
}
#cert-canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

/* RESPONSIVE Avanzado */
@media (min-width: 768px) {
    .drop-zones-grid {
        grid-template-columns: 1fr 1fr;
    }
    .drop-zones-grid.dual-col {
        grid-template-columns: 1fr 1fr;
    }
    .segments-grid {
        grid-template-columns: 1fr 1fr;
    }
    .options-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
    .notifications-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .personaje-inicio { max-width: 240px; }
    .game-title { font-size: 1.8rem; }
    .game-subtitle { font-size: 1.1rem; }
    .main-logo { max-width: 180px; }
    header { padding: 8px 10px; }
    .logo { height: 28px; }
    .btn-primary { font-size: 1rem; padding: 12px 15px; }
    .coin-item { padding: 8px; font-size: 0.85rem; }
    .coin-val { width: 15px; }
    .draggables-pool { padding: 10px; min-height: 60px; }
    .draggable-card { padding: 6px 10px; font-size: 0.8rem; }
    .segment-box { flex-direction: column; text-align: center; }
    .segment-drop { width: 100%; margin-top: 5px; }
    .notification-actions { flex-direction: column; }
}

/* =====================================================
   PULIDO PROFESIONAL + CORRECCIÓN UX DRAG/TAP
   ===================================================== */
body {
    background:
        radial-gradient(circle at 20% 10%, rgba(235, 167, 31, 0.22), transparent 28%),
        radial-gradient(circle at 90% 35%, rgba(105, 32, 13, 0.35), transparent 26%),
        linear-gradient(135deg, #1A1110 0%, #351006 100%);
}

#app {
    background:
        radial-gradient(circle at 50% 0%, rgba(235, 167, 31, 0.10), transparent 35%),
        linear-gradient(180deg, #fffaf1 0%, var(--cream) 100%);
    overflow: hidden;
}

.screen {
    min-height: calc(100vh - 58px);
}

.screen.active {
    animation: screenEnter 0.45s ease both;
}

@keyframes screenEnter {
    from { opacity: 0; transform: translateY(14px) scale(0.99); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.zone-header {
    background: linear-gradient(135deg, var(--redwood), #8a2d12);
    color: #fff;
    border-radius: 18px;
    padding: 16px 18px;
    margin: 0 0 22px 0;
    box-shadow: 0 7px 0 var(--dark-brown), 0 12px 28px rgba(105,32,13,0.18);
    letter-spacing: .4px;
}

.btn-primary,
.btn-secondary,
.btn-zone,
.btn-option,
.draggable-card {
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: linear-gradient(180deg, #ffc13a 0%, var(--fuel-yellow) 60%, #d88b0b 100%);
    border: 2px solid rgba(255,255,255,0.35);
    box-shadow: 0 7px 0 var(--tahiti-gold), 0 14px 24px rgba(216,130,10,0.22);
}

.btn-secondary {
    background: linear-gradient(180deg, #843018 0%, var(--redwood) 100%);
    border: 2px solid rgba(255,255,255,0.20);
}

.btn:hover:not(:disabled),
.btn-option:hover,
.btn-zone:hover:not(:disabled) {
    filter: brightness(1.04);
}

.reto-container {
    background: rgba(255,255,255,0.36);
    border: 1px solid rgba(216,130,10,0.18);
    border-radius: 22px;
    padding: 20px;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.5), 0 10px 28px rgba(53,16,6,0.06);
}

.reto-container.hidden {
    display: none !important;
}

.draggables-pool {
    border: 2px solid rgba(216,130,10,0.12);
    background: rgba(53,16,6,0.06);
    box-shadow: inset 0 2px 10px rgba(53,16,6,0.04);
}

.draggables-pool:empty::after {
    content: 'Todas las tarjetas fueron colocadas';
    color: rgba(53,16,6,0.48);
    font-weight: 700;
    font-size: 0.9rem;
    padding: 6px;
}

.draggable-card {
    border: 0;
    appearance: none;
    -webkit-appearance: none;
    background: linear-gradient(180deg, #ffc23e 0%, var(--fuel-yellow) 68%, #d88b0b 100%);
    border-radius: 12px;
    box-shadow: 0 5px 0 var(--tahiti-gold), 0 7px 15px rgba(216,130,10,0.18);
    padding: 10px 14px;
    min-height: 42px;
    font-family: var(--font-heading);
    line-height: 1.15;
    text-align: center;
    will-change: transform;
}

.draggable-card:hover {
    transform: translateY(-2px);
}

.draggable-card.card-placed {
    font-size: 0.82rem;
    padding: 8px 10px;
    box-shadow: 0 3px 0 var(--tahiti-gold);
}

.card-selected {
    outline: 3px solid #fff;
    box-shadow: 0 0 0 4px var(--redwood), 0 8px 24px rgba(105,32,13,.32) !important;
    transform: translateY(-3px) scale(1.03) !important;
    animation: selectedPulse 1.2s ease-in-out infinite;
}

@keyframes selectedPulse {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.12); }
}

.card-dragging {
    opacity: .62;
    transform: rotate(-2deg) scale(1.03);
}

.drop-zone-container {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 20px rgba(53,16,6,0.09);
}

.drop-zone-container h4,
.segment-label {
    background: linear-gradient(135deg, var(--redwood), #7f260f);
    color: #fff;
    letter-spacing: .3px;
}

.drop-zone {
    min-height: 105px;
    border: 3px dashed rgba(53,16,6,0.20);
    background: rgba(255,255,255,0.82);
    align-content: flex-start;
}

.drop-zone:empty::after,
.segment-drop:empty::after {
    content: 'Toca aquí para colocar';
    color: rgba(43,43,43,0.35);
    font-size: 0.82rem;
    font-weight: 700;
    margin: auto;
    text-align: center;
}

.drop-zone.drag-over,
.drop-zone-active,
.draggables-pool.drag-over,
.draggables-pool.drop-zone-active {
    background: rgba(235,167,31,0.13) !important;
    border-color: var(--fuel-yellow) !important;
    box-shadow: inset 0 0 0 2px rgba(216,130,10,0.14), 0 0 0 3px rgba(235,167,31,0.18);
}

.interaction-hint {
    display: none;
    margin: 10px 0 14px 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: #fff4d8;
    border-left: 6px solid var(--fuel-yellow);
    color: var(--dark-brown);
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(216,130,10,0.12);
}

.interaction-hint.show {
    display: block;
    animation: hintIn .28s ease both;
}

@keyframes hintIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.segment-box {
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 8px 18px rgba(53,16,6,0.08);
}

.segment-label {
    border-radius: 10px;
}

.segment-drop {
    min-width: 130px;
    min-height: 56px;
}

.score-display {
    background: linear-gradient(180deg, #ffc13a 0%, var(--fuel-yellow) 100%);
    border: 2px solid rgba(255,255,255,.35);
}

.insignia-card {
    animation: rewardPop .55s cubic-bezier(.2,1.4,.4,1) both;
}

@keyframes rewardPop {
    from { opacity: 0; transform: scale(.82) rotate(-2deg); }
    to { opacity: 1; transform: scale(1) rotate(0); }
}

.trophy-img,
.personaje-inicio {
    filter: drop-shadow(0 20px 28px rgba(53,16,6,0.28));
}

@media (max-width: 768px) {
    #app {
        max-width: none;
        width: 100%;
        min-height: 100dvh;
    }
    .screen {
        padding: 16px;
    }
    .reto-container {
        padding: 16px;
    }
    .zone-header {
        font-size: 1.05rem;
        line-height: 1.35;
        padding: 14px 12px;
    }
    .drop-zones-grid,
    .drop-zones-grid.dual-col,
    .segments-grid,
    .options-grid,
    .notifications-grid {
        grid-template-columns: 1fr !important;
    }
    .drop-zone {
        min-height: 112px;
    }
    .draggable-card {
        min-height: 46px;
        padding: 10px 12px;
    }
}

@media (max-width: 480px) {
    .screen {
        padding: 14px;
    }
    .reto-container {
        padding: 14px;
        border-radius: 18px;
    }
    .home-container {
        padding-top: 8px;
    }
    .game-title {
        font-size: 1.65rem;
    }
    .btn-large {
        width: 100%;
        font-size: 1.1rem;
        padding: 16px 14px;
    }
    .draggables-pool {
        gap: 8px;
        padding: 12px;
    }
    .draggable-card {
        font-size: .84rem;
        flex: 1 1 auto;
    }
    .drop-zone-container h4 {
        padding: 10px;
    }
    .drop-zone {
        min-height: 120px;
        padding: 10px;
    }
    .segment-box {
        padding: 8px;
    }
    .segment-drop {
        min-height: 64px;
    }
    .code-display {
        font-size: .96rem;
        word-break: break-word;
        letter-spacing: 1px;
    }
}

/* HUD de vidas */
.hud-panel {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.lives-display {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 800;
    background: linear-gradient(180deg, #ffffff 0%, #ffe8e8 100%);
    color: var(--dark-brown);
    padding: 5px 12px;
    border-radius: 20px;
    box-shadow: 0 4px 0 rgba(105, 32, 13, 0.35);
    border: 2px solid rgba(255,255,255,.45);
}

.lives-display.lives-low {
    animation: lifePulse 0.95s ease-in-out infinite;
    background: linear-gradient(180deg, #fff2f2 0%, #ffd0d0 100%);
}

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

.game-over-card {
    max-width: 520px;
    text-align: center;
}

.game-over-icon {
    font-size: 4rem;
    margin-bottom: 8px;
}

#reto-6 .order-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

#reto-6 .selected-order {
    margin-top: 12px;
    min-height: 110px;
}

#reto-9 .tip-card {
    border-left: 6px solid var(--fuel-yellow);
}

@media (max-width: 768px) {
    header {
        gap: 8px;
    }
    .hud-panel {
        gap: 6px;
    }
    .score-display,
    .lives-display {
        font-size: 0.88rem;
        padding: 5px 9px;
    }
    #reto-6 .order-container {
        grid-template-columns: 1fr;
    }
}

/* RETO 6: orden flexible por casilleros */
#reto-6 .order-bank .btn-order.selected-step {
    outline: 3px solid #fff;
    box-shadow: 0 0 0 4px var(--redwood), 0 8px 24px rgba(105,32,13,.28);
    transform: translateY(-2px) scale(1.02);
}

#reto-6 .order-bank .btn-order.used-step {
    opacity: .45;
}

#reto-6 .order-slots {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 12px;
    border: 3px dashed rgba(53,16,6,0.20);
    border-radius: 16px;
    background: rgba(255,255,255,0.72);
    min-height: 0;
}

#reto-6 .order-slot {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 10px 12px;
    border: 2px dashed rgba(216,130,10,0.35);
    border-radius: 12px;
    background: rgba(255,255,255,0.86);
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

#reto-6 .order-slot:hover {
    background: #fff7df;
    box-shadow: 0 6px 18px rgba(216,130,10,0.12);
    transform: translateY(-1px);
}

#reto-6 .order-slot.filled {
    border-style: solid;
    border-color: var(--fuel-yellow);
    background: linear-gradient(180deg, #fff9e8 0%, #fff0c6 100%);
    box-shadow: 0 4px 0 rgba(216,130,10,0.35);
}

#reto-6 .slot-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--redwood);
    color: #fff;
    font-family: var(--font-heading);
    font-weight: 900;
    flex: 0 0 auto;
}

#reto-6 .slot-text {
    font-weight: 800;
    color: var(--dark-brown);
    line-height: 1.25;
}

@media (max-width: 480px) {
    #reto-6 .order-slot {
        min-height: 62px;
        align-items: flex-start;
    }
}


/* Ajustes finales: evitar que Reto 9 entregue pistas visuales por color antes de verificar */
#reto-9 .drop-zone.green-border,
#reto-9 .drop-zone.red-border {
    border-color: rgba(53,16,6,0.20) !important;
}
#reto-9 .drop-zone-container h4 {
    background: linear-gradient(135deg, var(--redwood), #7f260f) !important;
}
.neutral-tip {
    border-left-color: var(--fuel-yellow) !important;
}
